From a09ba2370b261530a1319c111c74ee710a2e09a5 Mon Sep 17 00:00:00 2001 From: Brendan Nee Date: Sat, 30 Apr 2022 16:43:22 -0700 Subject: [PATCH] Rename Syncromatics to GMV --- CHANGELOG.md | 2 + lib/import-apc.js | 80 ++++++++++---------- lib/import-types/{syncromatics.js => gmv.js} | 2 +- 3 files changed, 43 insertions(+), 41 deletions(-) rename lib/import-types/{syncromatics.js => gmv.js} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index d216a40..a63adfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Add support for Swiftly +### Changed +- Renamed Syncromatics to GMV ### Updated - Dependency updates diff --git a/lib/import-apc.js b/lib/import-apc.js index 9be21ed..e7ffb82 100644 --- a/lib/import-apc.js +++ b/lib/import-apc.js @@ -20,7 +20,7 @@ import { formatCETLine } from './import-types/cet.js'; import { formatLTDLine } from './import-types/ltd.js'; import { formatRVTDLine } from './import-types/rvtd.js'; import { formatSwiftlyLine } from './import-types/swiftly.js'; -import { formatSyncromaticsLine } from './import-types/syncromatics.js'; +import { formatGMVLine } from './import-types/gmv.js'; import { formatWETALine } from './import-types/weta.js'; const getAPCType = recordFieldNames => { @@ -32,6 +32,35 @@ const getAPCType = recordFieldNames => { 'Exits', ]; + const gmvRequiredFieldNames = [ + 'VehicleId', + 'VehicleName', + 'RouteId', + 'RouteName', + 'PatternId', + 'PatternName', + 'StopId', + 'StopName', + 'StopNumber', + 'Timepoint', + 'TripId', + 'TripName', + 'RunId', + 'RunName', + 'BlockId', + 'Arrive', + 'ArriveVariance', + 'ScheduledArrive', + 'Depart', + 'DepartVariance', + 'ScheduledDepart', + 'Ons', + 'Offs', + 'ArrivalPassengers', + 'VehicleCapacity', + 'DeparturePassengers', + ]; + const ltdRequiredFieldNames = [ 'stop', 'trip_sn', @@ -77,35 +106,6 @@ const getAPCType = recordFieldNames => { 'BikesOff', ]; - const syncromaticsRequiredFieldNames = [ - 'VehicleId', - 'VehicleName', - 'RouteId', - 'RouteName', - 'PatternId', - 'PatternName', - 'StopId', - 'StopName', - 'StopNumber', - 'Timepoint', - 'TripId', - 'TripName', - 'RunId', - 'RunName', - 'BlockId', - 'Arrive', - 'ArriveVariance', - 'ScheduledArrive', - 'Depart', - 'DepartVariance', - 'ScheduledDepart', - 'Ons', - 'Offs', - 'ArrivalPassengers', - 'VehicleCapacity', - 'DeparturePassengers', - ]; - const swiftlyRequiredFieldNames = [ 'service_date', 'actual_time', @@ -121,6 +121,10 @@ const getAPCType = recordFieldNames => { return 'cet'; } + if (gmvRequiredFieldNames.every(fieldName => recordFieldNames.includes(fieldName))) { + return 'gmv'; + } + if (ltdRequiredFieldNames.every(fieldName => recordFieldNames.includes(fieldName))) { return 'ltd'; } @@ -133,10 +137,6 @@ const getAPCType = recordFieldNames => { return 'swiftly'; } - if (syncromaticsRequiredFieldNames.every(fieldName => recordFieldNames.includes(fieldName))) { - return 'syncromatics'; - } - if (wetaRequiredFieldNames.every(fieldName => recordFieldNames.includes(fieldName))) { return 'weta'; } @@ -154,6 +154,12 @@ const convertToBoardAlights = async (line, config) => { break; } + case 'gmv': { + boardAlightLines.push(await formatGMVLine(line)); + + break; + } + case 'ltd': { boardAlightLines.push(await formatLTDLine(line)); @@ -172,12 +178,6 @@ const convertToBoardAlights = async (line, config) => { break; } - case 'syncromatics': { - boardAlightLines.push(await formatSyncromaticsLine(line)); - - break; - } - case 'weta': { boardAlightLines.push(...await formatWETALine(line)); diff --git a/lib/import-types/syncromatics.js b/lib/import-types/gmv.js similarity index 96% rename from lib/import-types/syncromatics.js rename to lib/import-types/gmv.js index 5c7a293..b2f8330 100644 --- a/lib/import-types/syncromatics.js +++ b/lib/import-types/gmv.js @@ -2,7 +2,7 @@ import { getStops, getTrips } from 'gtfs'; import { DateTime } from 'luxon'; import { getServiceIdsByDate, findClosestTripByTime, findClosestStoptimeByTime } from '../utils.js'; -export const formatSyncromaticsLine = async ({ record, lineNumber }) => { +export const formatGMVLine = async ({ record, lineNumber }) => { const stops = await getStops({ stop_id: record.StopId }, ['stop_id']); if (stops.length === 0) {