gtfs 4.17.1 → 4.17.3

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.
package/dist/index.js CHANGED
@@ -945,7 +945,6 @@ var riderCategories = {
945
945
  {
946
946
  name: "is_default_fare_category",
947
947
  type: "integer",
948
- required: true,
949
948
  min: 0,
950
949
  max: 1
951
950
  },
@@ -3851,18 +3850,6 @@ async function updateGtfsRealtime(initialConfig) {
3851
3850
  }
3852
3851
 
3853
3852
  // src/lib/import-gtfs.ts
3854
- var timeCache = {};
3855
- var formatAndCacheTime = (value) => {
3856
- const cached = timeCache[value];
3857
- if (cached !== void 0) {
3858
- return cached;
3859
- }
3860
- const timeAsSecondsFromMidnight = calculateSecondsFromMidnight(value);
3861
- const timeAsString = padLeadingZeros(value);
3862
- const computed = [timeAsSecondsFromMidnight, timeAsString];
3863
- timeCache[value] = computed;
3864
- return computed;
3865
- };
3866
3853
  var getTextFiles = async (folderPath) => {
3867
3854
  const files = await readdir(folderPath);
3868
3855
  return files.filter((filename) => filename.slice(-3) === "txt");
@@ -3974,7 +3961,16 @@ var createGtfsTables = (db) => {
3974
3961
  );
3975
3962
  if (column.type === "time") {
3976
3963
  sqlColumnCreateStatements.push(
3977
- `${getTimestampColumnName(column.name)} INTEGER`
3964
+ `${getTimestampColumnName(column.name)} INTEGER GENERATED ALWAYS AS (
3965
+ CASE
3966
+ WHEN ${column.name} IS NULL OR ${column.name} = '' THEN NULL
3967
+ ELSE CAST(
3968
+ substr(${column.name}, 1, instr(${column.name}, ':') - 1) * 3600 +
3969
+ substr(${column.name}, instr(${column.name}, ':') + 1, 2) * 60 +
3970
+ substr(${column.name}, -2) AS INTEGER
3971
+ )
3972
+ END
3973
+ ) STORED`
3978
3974
  );
3979
3975
  }
3980
3976
  }
@@ -4019,9 +4015,6 @@ var formatGtfsLine = (line, model, totalLineCount) => {
4019
4015
  let value = line[name];
4020
4016
  if (value === "" || value === void 0 || value === null) {
4021
4017
  formattedLine[name] = null;
4022
- if (type === "time") {
4023
- formattedLine[getTimestampColumnName(name)] = null;
4024
- }
4025
4018
  if (required) {
4026
4019
  throw new Error(
4027
4020
  `Missing required value in ${filenameBase}.${filenameExtension} for ${name} on line ${lineNumber}.`
@@ -4037,9 +4030,7 @@ var formatGtfsLine = (line, model, totalLineCount) => {
4037
4030
  );
4038
4031
  }
4039
4032
  } else if (type === "time") {
4040
- const [timeAsSecondsFromMidnight, timeAsString] = formatAndCacheTime(value);
4041
- value = timeAsString;
4042
- formattedLine[getTimestampColumnName(name)] = timeAsSecondsFromMidnight ?? null;
4033
+ value = padLeadingZeros(value);
4043
4034
  }
4044
4035
  if (type === "json") {
4045
4036
  value = JSON.stringify(value);
@@ -4072,19 +4063,7 @@ var importGtfsFiles = (db, task) => mapSeries2(
4072
4063
  return;
4073
4064
  }
4074
4065
  task.log(`Importing - ${filename}\r`);
4075
- const columns = model.schema.flatMap((column) => {
4076
- if (column.type === "time") {
4077
- return [
4078
- column,
4079
- {
4080
- name: getTimestampColumnName(column.name),
4081
- type: "integer",
4082
- index: true
4083
- }
4084
- ];
4085
- }
4086
- return column;
4087
- });
4066
+ const columns = model.schema;
4088
4067
  const prefixedColumns = new Set(
4089
4068
  columns.filter((column) => column.prefix).map((column) => column.name)
4090
4069
  );