gtfs 4.15.3 → 4.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3793,6 +3793,9 @@ var importGtfsFiles = (db, task) => mapSeries2(
3793
3793
  task.log(`Importing - ${filename}\r`);
3794
3794
  const columns = model.schema.filter((column) => column.name !== "id");
3795
3795
  const placeholder = columns.map(({ name }) => `@${name}`).join(", ");
3796
+ const prefixedColumns = new Set(
3797
+ columns.filter((col) => col.prefix).map((col) => col.name)
3798
+ );
3796
3799
  const prepareStatement = `INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${columns.map((column) => column.name).join(", ")}) VALUES (${placeholder})`;
3797
3800
  const insert = db.prepare(prepareStatement);
3798
3801
  const insertLines = db.transaction((lines) => {
@@ -3806,7 +3809,7 @@ var importGtfsFiles = (db, task) => mapSeries2(
3806
3809
  line
3807
3810
  ).map(([columnName, value]) => [
3808
3811
  columnName,
3809
- columns.find((col) => col.name === columnName)?.prefix ? `${task.prefix}${value}` : value
3812
+ prefixedColumns.has(columnName) && value !== null ? `${task.prefix}${value}` : value
3810
3813
  ])
3811
3814
  );
3812
3815
  insert.run(prefixedLine);
@@ -3905,13 +3908,10 @@ async function importGtfs(initialConfig) {
3905
3908
  timer.start();
3906
3909
  const config = setDefaultConfig(initialConfig);
3907
3910
  validateConfigForImport(config);
3908
- const log2 = log(config);
3909
- const logError2 = logError(config);
3910
- const logWarning2 = logWarning(config);
3911
3911
  try {
3912
3912
  const db = openDb(config);
3913
3913
  const agencyCount = config.agencies.length;
3914
- log2(
3914
+ log(config)(
3915
3915
  `Starting GTFS import for ${pluralize2("file", agencyCount, true)} using SQLite database at ${config.sqlitePath}`
3916
3916
  );
3917
3917
  createGtfsTables(db);
@@ -3935,9 +3935,9 @@ async function importGtfs(initialConfig) {
3935
3935
  sqlitePath: config.sqlitePath,
3936
3936
  prefix: agency2.prefix,
3937
3937
  currentTimestamp: Math.floor(Date.now() / 1e3),
3938
- log: log2,
3939
- logWarning: logWarning2,
3940
- logError: logError2
3938
+ log: log(config),
3939
+ logWarning: logWarning(config),
3940
+ logError: logError(config)
3941
3941
  };
3942
3942
  if (task.url) {
3943
3943
  await downloadGtfsFiles(task);
@@ -3947,36 +3947,30 @@ async function importGtfs(initialConfig) {
3947
3947
  await updateGtfsRealtimeData(task);
3948
3948
  await rm2(tempPath, { recursive: true });
3949
3949
  } catch (error) {
3950
- handleImportError(error, config, logError2);
3950
+ if (config.ignoreErrors) {
3951
+ logError(config)(error.message);
3952
+ } else {
3953
+ throw error;
3954
+ }
3951
3955
  }
3952
3956
  });
3953
- log2(`Creating DB indexes`);
3957
+ log(config)(`Creating DB indexes`);
3954
3958
  createGtfsIndexes(db);
3955
3959
  const seconds = Math.round(timer.time() / 1e3);
3956
3960
  timer.stop();
3957
- log2(
3961
+ log(config)(
3958
3962
  `Completed GTFS import for ${pluralize2("agency", agencyCount, true)} in ${seconds} seconds
3959
3963
  `
3960
3964
  );
3961
3965
  } catch (error) {
3962
- handleDatabaseError(error, config, logError2);
3963
- }
3964
- }
3965
- function handleImportError(error, config, logError2) {
3966
- if (config.ignoreErrors) {
3967
- logError2(error.message);
3968
- } else {
3966
+ if (error?.code === "SQLITE_CANTOPEN") {
3967
+ logError(config)(
3968
+ `Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
3969
+ );
3970
+ }
3969
3971
  throw error;
3970
3972
  }
3971
3973
  }
3972
- function handleDatabaseError(error, config, logError2) {
3973
- if (error?.code === "SQLITE_CANTOPEN") {
3974
- logError2(
3975
- `Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
3976
- );
3977
- }
3978
- throw error;
3979
- }
3980
3974
 
3981
3975
  // src/lib/export.ts
3982
3976
  import { without, compact as compact2 } from "lodash-es";