Skip to content

Commit

Permalink
Add ignoreMissingGTFSDates config option
Browse files Browse the repository at this point in the history
  • Loading branch information
brendannee committed Mar 4, 2024
1 parent 0232ab1 commit 94fae3d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
| [`startDate`](#startDate) | int | Optional. Ignore all APC data before this date. |
| [`endDate`](#endDate) | int | Optional. Ignore all APC data after this date. |
| [`mergeDuplicateBoardAlights`](#mergeduplicateboardalights) | boolean | Whether or not to merge duplicate board-alight records by summing them. Defaults to `false`. |
| [`ignoreMissingGTFSDates`](#ignoremissinggtfsdates) | string | Ignore errors caused by no service in GTFS. |
| [`sqlitePath`](#sqlitepath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
| [`swiftlyAgencyKey`](#swiftlyagencykey) | string | The Swiftly agency key to request data for. |
| [`swiftlyAPIKey`](#swiftlyapikey) | string | The API key for the Swiftly API. |
Expand Down Expand Up @@ -203,6 +204,14 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
"mergeDuplicateBoardAlights": "false
```

### ignoreMissingGTFSDates

{Boolean} Whether or not to ignore errors caused by no service defined for a specific date in GTFS. Defaults to `false`.

```
"ignoreMissingGTFSDates": "false
```

### sqlitePath

{String} A path to an SQLite database. Optional, defaults to using an in-memory database.
Expand Down
3 changes: 2 additions & 1 deletion config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"apcPath": "data/RVTD/boardings_alightings_rvtd_2017.csv",
"mergeDuplicateBoardAlights": false,
"startDate": 20170101,
"endDate": 20170301
"endDate": 20170301,
"ignoreMissingGTFSDates": false
}
3 changes: 3 additions & 0 deletions lib/import-apc.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ const convertToBoardAlights = (line, config) => {
cleanLine(line, boardAlightModel, config),
);
} catch (error) {
if (config.ignoreMissingGTFSDates && error.cause === 'no-service-ids') {
return [];
}
config.recordIssue(`${error.message} on line ${line.lineNumber}`);
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/import-types/gmv.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const formatGMVLine = ({ record, lineNumber }) => {

if (serviceIds.length === 0) {
throw new Error(
`No service_ids found for calendar_date \`${record.ScheduledArrive}\``,
`No service_ids found for calendar_date \`${scheduledArrivalTime.toFormat('yyyyMMdd')}\``,
{ cause: 'no-service-ids' },
);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/import-types/ltd.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const formatLTDLine = ({ record, lineNumber }) => {

if (serviceIds.length === 0) {
throw new Error(
`No service_ids found for calendar_date \`${record.calendar_date}\``,
`No service_ids found for calendar_date \`${serviceDate}\``,
{ cause: 'no-service-ids' },
);
}

Expand Down

0 comments on commit 94fae3d

Please sign in to comment.