Skip to content

Commit

Permalink
Rename Syncromatics to GMV
Browse files Browse the repository at this point in the history
  • Loading branch information
brendannee committed Apr 30, 2022
1 parent 6c50904 commit a09ba23
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
80 changes: 40 additions & 40 deletions lib/import-apc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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';
}
Expand All @@ -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';
}
Expand All @@ -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));

Expand All @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a09ba23

Please sign in to comment.