diff --git a/README.md b/README.md index 3036550..80bd8dc 100644 --- a/README.md +++ b/README.md @@ -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. | @@ -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. diff --git a/config-sample.json b/config-sample.json index a1a4fb0..6c769e6 100644 --- a/config-sample.json +++ b/config-sample.json @@ -3,5 +3,6 @@ "apcPath": "data/RVTD/boardings_alightings_rvtd_2017.csv", "mergeDuplicateBoardAlights": false, "startDate": 20170101, - "endDate": 20170301 + "endDate": 20170301, + "ignoreMissingGTFSDates": false } diff --git a/lib/import-apc.js b/lib/import-apc.js index 4245f7d..9f83002 100644 --- a/lib/import-apc.js +++ b/lib/import-apc.js @@ -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 []; } diff --git a/lib/import-types/gmv.js b/lib/import-types/gmv.js index 20185f8..4238a26 100644 --- a/lib/import-types/gmv.js +++ b/lib/import-types/gmv.js @@ -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' }, ); } diff --git a/lib/import-types/ltd.js b/lib/import-types/ltd.js index fcc1a95..ed29213 100644 --- a/lib/import-types/ltd.js +++ b/lib/import-types/ltd.js @@ -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' }, ); }