From fad5e813c207bb6e4eec01f93f6a86618697ab33 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:41:00 -0400 Subject: [PATCH 01/12] fix(live-stop-times): Display departures on separate days as separate days. --- __tests__/util/stop-data.json | 286 +++++++++++++++++++++ __tests__/util/stop-times.ts | 61 +++++ lib/components/util/types.ts | 14 +- lib/components/viewers/live-stop-times.tsx | 44 +--- lib/util/stop-times.ts | 74 ++++++ 5 files changed, 438 insertions(+), 41 deletions(-) create mode 100644 __tests__/util/stop-data.json create mode 100644 __tests__/util/stop-times.ts create mode 100644 lib/util/stop-times.ts diff --git a/__tests__/util/stop-data.json b/__tests__/util/stop-data.json new file mode 100644 index 000000000..653b2f66d --- /dev/null +++ b/__tests__/util/stop-data.json @@ -0,0 +1,286 @@ +{ + "id": "40:99256", + "code": "C15-T2", + "lat": 47.580589, + "lon": -122.327263, + "locationType": "STOP", + "name": "SODO Station", + "wheelchairBoarding": "POSSIBLE", + "zoneId": "73", + "geometries": { + "geoJson": { + "type": "Point", + "coordinates": [ + -122.3273, + 47.5806 + ] + } + }, + "routes": [ + { + "id": "40:100479", + "agency": { + "gtfsId": "40:40", + "name": "Sound Transit" + }, + "longName": "Northgate - Angle Lake", + "mode": "TRAM", + "color": "28813F", + "textColor": "FFFFFF", + "shortName": "1-Line" + } + ], + "stopTimes": [ + { + "pattern": { + "id": "40:100479:1:01", + "desc": "1-Line to Northgate Station (40:990006) from Angle Lake Station (40:99914)", + "routeId": "40:100479", + "headsign": "Northgate" + }, + "times": [ + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 19, + "scheduledArrival": 23850, + "scheduledDeparture": 23880, + "realtimeArrival": 23850, + "realtimeDeparture": 23880, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1016", + "blockId": "59906", + "headsign": "Northgate" + }, + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 19, + "scheduledArrival": 23370, + "scheduledDeparture": 23400, + "realtimeArrival": 23370, + "realtimeDeparture": 23400, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1014", + "blockId": "59905", + "headsign": "Northgate" + }, + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 19, + "scheduledArrival": 22890, + "scheduledDeparture": 22920, + "realtimeArrival": 22890, + "realtimeDeparture": 22920, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1013", + "blockId": "59904", + "headsign": "Northgate" + } + ] + }, + { + "pattern": { + "id": "40:100479:1:06", + "desc": "1-Line University of Washington", + "routeId": "40:100479", + "headsign": "University of Washington" + }, + "times": [ + { + "stopId": "40:99256", + "stopIndex": 0, + "stopCount": 8, + "scheduledArrival": 15810, + "scheduledDeparture": 15840, + "realtimeArrival": 15810, + "realtimeDeparture": 15840, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695366000, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1001", + "blockId": "59904", + "headsign": "University of Washington" + }, + { + "stopId": "40:99256", + "stopIndex": 0, + "stopCount": 8, + "scheduledArrival": 15810, + "scheduledDeparture": 15840, + "realtimeArrival": 15810, + "realtimeDeparture": 15840, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695279600, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1001", + "blockId": "59904", + "headsign": "University of Washington" + } + ] + }, + { + "pattern": { + "id": "40:100479:1:07", + "desc": "1-Line Stadium", + "routeId": "40:100479", + "headsign": "Stadium" + }, + "times": [ + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 10, + "scheduledArrival": 90090, + "scheduledDeparture": 90120, + "realtimeArrival": 90090, + "realtimeDeparture": 90120, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1132", + "blockId": "59904", + "headsign": "Stadium" + }, + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 10, + "scheduledArrival": 89190, + "scheduledDeparture": 89220, + "realtimeArrival": 89190, + "realtimeDeparture": 89220, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1131", + "blockId": "59924", + "headsign": "Stadium" + }, + { + "stopId": "40:99256", + "stopIndex": 8, + "stopCount": 10, + "scheduledArrival": 88290, + "scheduledDeparture": 88320, + "realtimeArrival": 88290, + "realtimeDeparture": 88320, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1130", + "blockId": "59903", + "headsign": "Stadium" + } + ] + }, + { + "pattern": { + "id": "40:100479:1:05", + "desc": "1-Line to Northgate Station (40:990006) from SODO Station (40:99256)", + "routeId": "40:100479", + "headsign": "Northgate" + }, + "times": [ + { + "stopId": "40:99256", + "stopIndex": 0, + "stopCount": 11, + "scheduledArrival": 17250, + "scheduledDeparture": 17280, + "realtimeArrival": 17250, + "realtimeDeparture": 17280, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695279600, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1003", + "blockId": "59908", + "headsign": "Northgate" + }, + { + "stopId": "40:99256", + "stopIndex": 0, + "stopCount": 11, + "scheduledArrival": 16530, + "scheduledDeparture": 16560, + "realtimeArrival": 16530, + "realtimeDeparture": 16560, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695279600, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1002", + "blockId": "59922", + "headsign": "Northgate" + }, + { + "stopId": "40:99256", + "stopIndex": 0, + "stopCount": 11, + "scheduledArrival": 52470, + "scheduledDeparture": 52500, + "realtimeArrival": 52470, + "realtimeDeparture": 52500, + "arrivalDelay": 0, + "departureDelay": 0, + "timepoint": true, + "realtime": false, + "realtimeState": "SCHEDULED", + "serviceDay": 1695193200, + "tripId": "40:LLR_2023-09-18_Sept18_Weekday_100479_1072", + "blockId": "59925", + "headsign": "Northgate" + } + ] + } + ], + "agencyId": "40:40", + "agencyName": "Sound Transit", + "color": "#28813F", + "bikeRental": { + "stations": [] + }, + "parkAndRideLocations": [], + "vehicleRental": { + "stations": [] + }, + "nearbyStops": [], + "fetchStatus": 2, + "stopTimesLastUpdated": 1695215706401 +} \ No newline at end of file diff --git a/__tests__/util/stop-times.ts b/__tests__/util/stop-times.ts new file mode 100644 index 000000000..d11c738d7 --- /dev/null +++ b/__tests__/util/stop-times.ts @@ -0,0 +1,61 @@ +import { utcToZonedTime } from 'date-fns-tz' + +import '../test-utils/mock-window-url' +import { groupAndSortStopTimesByPatternByDay } from '../../lib/util/stop-times' + +const stopData = require('./stop-data.json') +const now = utcToZonedTime( + new Date(stopData.stopTimesLastUpdated), + 'America/Los_Angeles' +) +const daysAhead = 2 + +describe('util > stop-times', () => { + describe('sortAndGroupStopTimesByDay', () => { + it('should sort and group stop times by day', () => { + const stopTimesByPatternByDay = groupAndSortStopTimesByPatternByDay( + stopData, + now, + daysAhead + ) + + // Stop time data has 4 patterns aggregating to 3 final destinations. + // (This method assumes that the routing is roughly the same for patterns + // that have the same destination.) + const headsigns = new Set( + stopTimesByPatternByDay.map((st) => st.pattern.headsign) + ) + expect(headsigns.size).toBe(3) + expect(headsigns).toContain('Northgate') + expect(headsigns).toContain('Stadium') + expect(headsigns).toContain('University of Washington') + + // The pattern to University of Washington should be included twice, + // once per service day outside of today. + const uwaPatternDays = stopTimesByPatternByDay + .filter((p) => p.id === '40:100479-University of Washington') + .map((p) => p.day) + expect(uwaPatternDays).toEqual([1695279600, 1695366000]) + + // Patterns to Stadium (last trips in the evening) should be for "today's" service day. + const stadiumPatternDays = stopTimesByPatternByDay + .filter((p) => p.id === '40:100479-Stadium') + .map((p) => p.day) + expect(stadiumPatternDays).toEqual([1695193200]) + + // Patterns should be sorted by day. + for (let i = 1; i < stopTimesByPatternByDay.length; i++) { + const prevPattern = stopTimesByPatternByDay[i - 1] + const thisPattern = stopTimesByPatternByDay[i] + expect(prevPattern.day).toBeLessThanOrEqual(thisPattern.day) + + if (prevPattern.day === thisPattern.day) { + // eslint-disable-next-line jest/no-conditional-expect + expect(prevPattern.times[0].realtimeDeparture).toBeLessThanOrEqual( + thisPattern.times[0].realtimeDeparture + ) + } + } + }) + }) +}) diff --git a/lib/components/util/types.ts b/lib/components/util/types.ts index febaa585d..56fa106e9 100644 --- a/lib/components/util/types.ts +++ b/lib/components/util/types.ts @@ -24,13 +24,19 @@ export interface BikeRental { stations: any[] } -// FIXME: incomplete export interface StopTime { - departureDelay: number + departureDelay?: number headsign: string pattern: Pattern - realtimeDeparture: boolean - realtimeState: string + realtimeDeparture?: boolean + realtimeState?: string + times: Time[] +} + +export interface StopTimesForPattern { + id: string + pattern: Pattern + route: Route times: Time[] } diff --git a/lib/components/viewers/live-stop-times.tsx b/lib/components/viewers/live-stop-times.tsx index e8a772024..9946e512b 100644 --- a/lib/components/viewers/live-stop-times.tsx +++ b/lib/components/viewers/live-stop-times.tsx @@ -1,4 +1,3 @@ -import { addDays, isBefore } from 'date-fns' import { format, utcToZonedTime } from 'date-fns-tz' import { FormattedMessage, @@ -12,13 +11,7 @@ import coreUtils from '@opentripplanner/core-utils' import isSameDay from 'date-fns/isSameDay' import React, { Component } from 'react' -import { - getRouteIdForPattern, - getStopTimesByPattern, - patternComparator, - routeIsValid, - stopTimeComparator -} from '../../util/viewer' +import { groupAndSortStopTimesByPatternByDay } from '../../util/stop-times' import { IconWithText } from '../util/styledIcon' import FormattedDayOfWeek from '../util/formatted-day-of-week' import SpanWithSpace from '../util/span-with-space' @@ -164,9 +157,6 @@ class LiveStopTimes extends Component { } = this.props const { spin } = this.state const userTimezone = getUserTimezone() - // construct a lookup table mapping pattern (e.g. 'ROUTE_ID-HEADSIGN') to - // an array of stoptimes - const stopTimesByPattern = getStopTimesByPattern(stopData) const now = utcToZonedTime(Date.now(), homeTimezone) // Time range is set in seconds, so convert to days @@ -176,33 +166,13 @@ class LiveStopTimes extends Component { id: 'components.LiveStopTimes.refresh' }) - const routeTimes = Object.values(stopTimesByPattern) - .filter( - ({ pattern, route, times }) => - times && - times.length !== 0 && - routeIsValid(route, getRouteIdForPattern(pattern)) - ) - .sort(patternComparator) - .map((route) => { - const sortedTimes = route.times - .concat() - ?.sort(stopTimeComparator) - // filter any times according to time range set in config. - .filter((time: any, i: number, array: Array) => { - const departureTime = time.serviceDay + time.realtimeDeparture - return isBefore(departureTime, addDays(now, timeRange)) - }) - const { serviceDay } = sortedTimes[0] - return { - ...route, - day: serviceDay || null, - times: sortedTimes - } - }) - // if the time range filter removes all times, remove route - .filter(({ times }) => times.length !== 0) + const routeTimes = groupAndSortStopTimesByPatternByDay( + stopData, + now, + timeRange + ) + console.log('route times', routeTimes) return ( <>
    diff --git a/lib/util/stop-times.ts b/lib/util/stop-times.ts new file mode 100644 index 000000000..246f3fde6 --- /dev/null +++ b/lib/util/stop-times.ts @@ -0,0 +1,74 @@ +import { addDays, isBefore } from 'date-fns' + +import { StopTimesForPattern } from '../components/util/types' + +import { + getRouteIdForPattern, + getStopTimesByPattern, + patternComparator, + routeIsValid, + stopTimeComparator +} from './viewer' + +/** Helper to sort and group stop times by pattern by service day */ +export function groupAndSortStopTimesByPatternByDay( + stopData: Record, + now: Date, + daysAhead: number +) { + // construct a lookup table mapping pattern (e.g. 'ROUTE_ID-HEADSIGN') to + // an array of stoptimes + const stopTimesByPattern = getStopTimesByPattern(stopData) + + const routeTimes = [] + Object.values(stopTimesByPattern) + .filter( + ({ pattern, route, times }) => + times && + times.length !== 0 && + routeIsValid(route, getRouteIdForPattern(pattern)) + ) + .sort(patternComparator) + .forEach((route) => { + const sortedTimes = route.times + .concat() + ?.sort(stopTimeComparator) + // filter any times according to time range set in config. + .filter((time: any, i: number, array: Array) => { + const departureTime = time.serviceDay + time.realtimeDeparture + return isBefore(departureTime, addDays(now, daysAhead)) + }) + + const serviceDays = {} + const serviceDayList = [] + sortedTimes.forEach((t) => { + const { serviceDay } = t + if (!serviceDays[serviceDay]) { + serviceDays[serviceDay] = [] + serviceDayList.push(serviceDay) + } + serviceDays[serviceDay].push(t) + }) + + serviceDayList.forEach((day) => { + // Don't return patterns with no times within the days ahead. + const times = serviceDays[day] + if (times.length !== 0) { + routeTimes.push({ + ...route, + day, + times + }) + } + }) + }) + + // Sort route times by service day then realtime departure + routeTimes.sort( + (rt1, rt2) => + (rt1.day - rt2.day) * 100000 + + (rt1.times[0].realtimeDeparture - rt2.times[0].realtimeDeparture) + ) + + return routeTimes +} From bb00238287fb5387ffe60f168ccb70e9f25ce1cd Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:14:09 -0400 Subject: [PATCH 02/12] fix(stop-times): Don't show next-day departures if same-day departures exist for a pattern. --- __tests__/util/stop-times.ts | 10 ++++++++- lib/components/viewers/live-stop-times.tsx | 3 ++- lib/util/stop-times.ts | 25 ++++++++++++---------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/__tests__/util/stop-times.ts b/__tests__/util/stop-times.ts index d11c738d7..44b86987e 100644 --- a/__tests__/util/stop-times.ts +++ b/__tests__/util/stop-times.ts @@ -16,7 +16,8 @@ describe('util > stop-times', () => { const stopTimesByPatternByDay = groupAndSortStopTimesByPatternByDay( stopData, now, - daysAhead + daysAhead, + 3 ) // Stop time data has 4 patterns aggregating to 3 final destinations. @@ -43,6 +44,13 @@ describe('util > stop-times', () => { .map((p) => p.day) expect(stadiumPatternDays).toEqual([1695193200]) + // There is a same-day pattern to Northgate, + // therefore, no next-day pattern to Northgate should be returned. + const northgatePatternDays = stopTimesByPatternByDay + .filter((p) => p.id === '40:100479-Northgate') + .map((p) => p.day) + expect(northgatePatternDays).toEqual([1695193200]) + // Patterns should be sorted by day. for (let i = 1; i < stopTimesByPatternByDay.length; i++) { const prevPattern = stopTimesByPatternByDay[i - 1] diff --git a/lib/components/viewers/live-stop-times.tsx b/lib/components/viewers/live-stop-times.tsx index 9946e512b..b26462405 100644 --- a/lib/components/viewers/live-stop-times.tsx +++ b/lib/components/viewers/live-stop-times.tsx @@ -169,7 +169,8 @@ class LiveStopTimes extends Component { const routeTimes = groupAndSortStopTimesByPatternByDay( stopData, now, - timeRange + timeRange, + stopViewerConfig.numberOfDepartures ) console.log('route times', routeTimes) diff --git a/lib/util/stop-times.ts b/lib/util/stop-times.ts index 246f3fde6..8f2fd68fe 100644 --- a/lib/util/stop-times.ts +++ b/lib/util/stop-times.ts @@ -14,13 +14,14 @@ import { export function groupAndSortStopTimesByPatternByDay( stopData: Record, now: Date, - daysAhead: number + daysAhead: number, + numberOfDepartures: number ) { // construct a lookup table mapping pattern (e.g. 'ROUTE_ID-HEADSIGN') to // an array of stoptimes const stopTimesByPattern = getStopTimesByPattern(stopData) - const routeTimes = [] + const patternTimes = [] Object.values(stopTimesByPattern) .filter( ({ pattern, route, times }) => @@ -29,8 +30,8 @@ export function groupAndSortStopTimesByPatternByDay( routeIsValid(route, getRouteIdForPattern(pattern)) ) .sort(patternComparator) - .forEach((route) => { - const sortedTimes = route.times + .forEach((pattern) => { + const sortedTimes = pattern.times .concat() ?.sort(stopTimeComparator) // filter any times according to time range set in config. @@ -38,6 +39,8 @@ export function groupAndSortStopTimesByPatternByDay( const departureTime = time.serviceDay + time.realtimeDeparture return isBefore(departureTime, addDays(now, daysAhead)) }) + // remove excess departure times + .slice(0, numberOfDepartures) const serviceDays = {} const serviceDayList = [] @@ -54,8 +57,8 @@ export function groupAndSortStopTimesByPatternByDay( // Don't return patterns with no times within the days ahead. const times = serviceDays[day] if (times.length !== 0) { - routeTimes.push({ - ...route, + patternTimes.push({ + ...pattern, day, times }) @@ -64,11 +67,11 @@ export function groupAndSortStopTimesByPatternByDay( }) // Sort route times by service day then realtime departure - routeTimes.sort( - (rt1, rt2) => - (rt1.day - rt2.day) * 100000 + - (rt1.times[0].realtimeDeparture - rt2.times[0].realtimeDeparture) + patternTimes.sort( + (pt1, pt2) => + (pt1.day - pt2.day) * 100000 + + (pt1.times[0].realtimeDeparture - pt2.times[0].realtimeDeparture) ) - return routeTimes + return patternTimes } From d1bc6d2d66d89c9a44239d0104dadc31b242baaa Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 15:31:11 -0400 Subject: [PATCH 03/12] test(stop-times): Refactor test file --- __tests__/util/stop-times.ts | 54 ++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/__tests__/util/stop-times.ts b/__tests__/util/stop-times.ts index 44b86987e..6d6ef8fb2 100644 --- a/__tests__/util/stop-times.ts +++ b/__tests__/util/stop-times.ts @@ -20,49 +20,43 @@ describe('util > stop-times', () => { 3 ) + function getPatternDays(id: string) { + return stopTimesByPatternByDay + .filter((p) => p.id === id) + .map((p) => p.day) + } + // Stop time data has 4 patterns aggregating to 3 final destinations. // (This method assumes that the routing is roughly the same for patterns // that have the same destination.) const headsigns = new Set( stopTimesByPatternByDay.map((st) => st.pattern.headsign) ) - expect(headsigns.size).toBe(3) - expect(headsigns).toContain('Northgate') - expect(headsigns).toContain('Stadium') - expect(headsigns).toContain('University of Washington') + expect(headsigns).toEqual( + new Set(['Northgate', 'Stadium', 'University of Washington']) + ) - // The pattern to University of Washington should be included twice, - // once per service day outside of today. - const uwaPatternDays = stopTimesByPatternByDay - .filter((p) => p.id === '40:100479-University of Washington') - .map((p) => p.day) - expect(uwaPatternDays).toEqual([1695279600, 1695366000]) + // The pattern to UWA should be included twice, once per service day outside of today. + expect(getPatternDays('40:100479-University of Washington')).toEqual([ + 1695279600, 1695366000 + ]) - // Patterns to Stadium (last trips in the evening) should be for "today's" service day. - const stadiumPatternDays = stopTimesByPatternByDay - .filter((p) => p.id === '40:100479-Stadium') - .map((p) => p.day) - expect(stadiumPatternDays).toEqual([1695193200]) + // Patterns to Stadium (last trips in the evening) should be for "today"'s service day. + expect(getPatternDays('40:100479-Stadium')).toEqual([1695193200]) - // There is a same-day pattern to Northgate, - // therefore, no next-day pattern to Northgate should be returned. - const northgatePatternDays = stopTimesByPatternByDay - .filter((p) => p.id === '40:100479-Northgate') - .map((p) => p.day) - expect(northgatePatternDays).toEqual([1695193200]) + // No next-day pattern to Northgate should be returned (same-day depatures exist). + expect(getPatternDays('40:100479-Northgate')).toEqual([1695193200]) - // Patterns should be sorted by day. + // Patterns should be sorted by day, then by departure time. for (let i = 1; i < stopTimesByPatternByDay.length; i++) { const prevPattern = stopTimesByPatternByDay[i - 1] const thisPattern = stopTimesByPatternByDay[i] - expect(prevPattern.day).toBeLessThanOrEqual(thisPattern.day) - - if (prevPattern.day === thisPattern.day) { - // eslint-disable-next-line jest/no-conditional-expect - expect(prevPattern.times[0].realtimeDeparture).toBeLessThanOrEqual( - thisPattern.times[0].realtimeDeparture - ) - } + expect( + prevPattern.day < thisPattern.day || + (prevPattern.day === thisPattern.day && + prevPattern.times[0].realtimeDeparture <= + thisPattern.times[0].realtimeDeparture) + ).toBe(true) } }) }) From 6139d2a088f57b0c3f08923fad9d08dddf65f4eb Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:07:44 -0400 Subject: [PATCH 04/12] refactor(stop-times): Fix type errors --- lib/components/util/types.ts | 18 +++++++----- lib/components/viewers/live-stop-times.tsx | 4 +-- lib/util/stop-times.ts | 33 ++++++++++++---------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lib/components/util/types.ts b/lib/components/util/types.ts index 56fa106e9..59cd7ae3e 100644 --- a/lib/components/util/types.ts +++ b/lib/components/util/types.ts @@ -33,13 +33,6 @@ export interface StopTime { times: Time[] } -export interface StopTimesForPattern { - id: string - pattern: Pattern - route: Route - times: Time[] -} - export interface Pattern { desc: string headsign: string @@ -72,6 +65,17 @@ export interface Time { tripId: string } +export interface PatternStopTimes { + id: string + pattern: Pattern + route: Route + times: Time[] +} + +export interface PatternDayStopTimes extends PatternStopTimes { + day: number +} + export interface VehicleRental { errorsByNetwork: { [key: string]: { message?: string; severity?: string } } systemInformationDataByNetwork: { diff --git a/lib/components/viewers/live-stop-times.tsx b/lib/components/viewers/live-stop-times.tsx index b26462405..5ec848715 100644 --- a/lib/components/viewers/live-stop-times.tsx +++ b/lib/components/viewers/live-stop-times.tsx @@ -160,7 +160,7 @@ class LiveStopTimes extends Component { const now = utcToZonedTime(Date.now(), homeTimezone) // Time range is set in seconds, so convert to days - const timeRange = stopViewerConfig.timeRange / 86400 || 2 + const daysAhead = stopViewerConfig.timeRange / 86400 || 2 const refreshButtonText = intl.formatMessage({ id: 'components.LiveStopTimes.refresh' @@ -169,7 +169,7 @@ class LiveStopTimes extends Component { const routeTimes = groupAndSortStopTimesByPatternByDay( stopData, now, - timeRange, + daysAhead, stopViewerConfig.numberOfDepartures ) diff --git a/lib/util/stop-times.ts b/lib/util/stop-times.ts index 8f2fd68fe..a1eed9eab 100644 --- a/lib/util/stop-times.ts +++ b/lib/util/stop-times.ts @@ -1,6 +1,11 @@ import { addDays, isBefore } from 'date-fns' -import { StopTimesForPattern } from '../components/util/types' +import { + PatternDayStopTimes, + PatternStopTimes, + StopData, + Time +} from '../components/util/types' import { getRouteIdForPattern, @@ -12,16 +17,19 @@ import { /** Helper to sort and group stop times by pattern by service day */ export function groupAndSortStopTimesByPatternByDay( - stopData: Record, + stopData: StopData, now: Date, daysAhead: number, numberOfDepartures: number -) { +): PatternDayStopTimes[] { // construct a lookup table mapping pattern (e.g. 'ROUTE_ID-HEADSIGN') to // an array of stoptimes - const stopTimesByPattern = getStopTimesByPattern(stopData) + const stopTimesByPattern = getStopTimesByPattern(stopData) as Record< + string, + PatternStopTimes + > - const patternTimes = [] + const patternTimes: PatternDayStopTimes[] = [] Object.values(stopTimesByPattern) .filter( ({ pattern, route, times }) => @@ -35,16 +43,16 @@ export function groupAndSortStopTimesByPatternByDay( .concat() ?.sort(stopTimeComparator) // filter any times according to time range set in config. - .filter((time: any, i: number, array: Array) => { + .filter((time: Time, i: number, array: Time[]) => { const departureTime = time.serviceDay + time.realtimeDeparture return isBefore(departureTime, addDays(now, daysAhead)) }) // remove excess departure times .slice(0, numberOfDepartures) - const serviceDays = {} - const serviceDayList = [] - sortedTimes.forEach((t) => { + const serviceDays: Record = {} + const serviceDayList: number[] = [] + sortedTimes.forEach((t: Time) => { const { serviceDay } = t if (!serviceDays[serviceDay]) { serviceDays[serviceDay] = [] @@ -67,11 +75,6 @@ export function groupAndSortStopTimesByPatternByDay( }) // Sort route times by service day then realtime departure - patternTimes.sort( - (pt1, pt2) => - (pt1.day - pt2.day) * 100000 + - (pt1.times[0].realtimeDeparture - pt2.times[0].realtimeDeparture) - ) - + patternTimes.sort(patternComparator) return patternTimes } From e69d029061bfaa947c702d03ee703e4cbb3dadd7 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:24:03 -0400 Subject: [PATCH 05/12] refactor(stop-times): Breakup long method. --- lib/util/stop-times.ts | 83 +++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/lib/util/stop-times.ts b/lib/util/stop-times.ts index a1eed9eab..474ee9d2e 100644 --- a/lib/util/stop-times.ts +++ b/lib/util/stop-times.ts @@ -15,6 +15,38 @@ import { stopTimeComparator } from './viewer' +function hasValidTimesAndRoute({ + pattern, + route, + times +}: PatternStopTimes): boolean { + return ( + times && + times.length !== 0 && + routeIsValid(route, getRouteIdForPattern(pattern)) + ) +} + +function sortAndFilterPatternTimes( + times: Time[], + now: Date, + daysAhead: number, + numberOfDepartures: number +): Time[] { + return ( + times + .concat() + ?.sort(stopTimeComparator) + // filter any times according to time range set in config. + .filter((time, i, array) => { + const departureTime = time.serviceDay + time.realtimeDeparture + return isBefore(departureTime, addDays(now, daysAhead)) + }) + // remove excess departure times + .slice(0, numberOfDepartures) + ) +} + /** Helper to sort and group stop times by pattern by service day */ export function groupAndSortStopTimesByPatternByDay( stopData: StopData, @@ -31,46 +63,29 @@ export function groupAndSortStopTimesByPatternByDay( const patternTimes: PatternDayStopTimes[] = [] Object.values(stopTimesByPattern) - .filter( - ({ pattern, route, times }) => - times && - times.length !== 0 && - routeIsValid(route, getRouteIdForPattern(pattern)) - ) - .sort(patternComparator) + .filter(hasValidTimesAndRoute) .forEach((pattern) => { - const sortedTimes = pattern.times - .concat() - ?.sort(stopTimeComparator) - // filter any times according to time range set in config. - .filter((time: Time, i: number, array: Time[]) => { - const departureTime = time.serviceDay + time.realtimeDeparture - return isBefore(departureTime, addDays(now, daysAhead)) - }) - // remove excess departure times - .slice(0, numberOfDepartures) + const sortedTimes = sortAndFilterPatternTimes( + pattern.times, + now, + daysAhead, + numberOfDepartures + ) - const serviceDays: Record = {} - const serviceDayList: number[] = [] + const patternDays: Record = {} sortedTimes.forEach((t: Time) => { const { serviceDay } = t - if (!serviceDays[serviceDay]) { - serviceDays[serviceDay] = [] - serviceDayList.push(serviceDay) - } - serviceDays[serviceDay].push(t) - }) - - serviceDayList.forEach((day) => { - // Don't return patterns with no times within the days ahead. - const times = serviceDays[day] - if (times.length !== 0) { - patternTimes.push({ + let patternDay = patternDays[serviceDay] + if (!patternDay) { + patternDays[serviceDay] = patternDay = { ...pattern, - day, - times - }) + day: serviceDay, + times: [] + } + patternTimes.push(patternDay) } + // Ensures that every pattern returned has stop times within the days ahead. + patternDay.times.push(t) }) }) From 9327d8ff04cc0086d7d3e07eb6c7991d52f87664 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:32:03 -0400 Subject: [PATCH 06/12] refactor(stop-times): Use map reduce --- lib/util/arrays.ts | 12 ++++++ lib/util/stop-times.ts | 83 ++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 48 deletions(-) create mode 100644 lib/util/arrays.ts diff --git a/lib/util/arrays.ts b/lib/util/arrays.ts new file mode 100644 index 000000000..d5429ae6c --- /dev/null +++ b/lib/util/arrays.ts @@ -0,0 +1,12 @@ +/** Retrieves a key from a dictionary or adds it with the desired value if absent. */ +export function getOrPutEntry( + entries: Record, + key: K, + newValue: (newKey: K) => V +): V { + let entry = entries[key] + if (!entry) { + entries[key] = entry = newValue(key) + } + return entry +} diff --git a/lib/util/stop-times.ts b/lib/util/stop-times.ts index 474ee9d2e..f58deae2f 100644 --- a/lib/util/stop-times.ts +++ b/lib/util/stop-times.ts @@ -7,6 +7,7 @@ import { Time } from '../components/util/types' +import { getOrPutEntry } from './arrays' import { getRouteIdForPattern, getStopTimesByPattern, @@ -27,24 +28,10 @@ function hasValidTimesAndRoute({ ) } -function sortAndFilterPatternTimes( - times: Time[], - now: Date, - daysAhead: number, - numberOfDepartures: number -): Time[] { - return ( - times - .concat() - ?.sort(stopTimeComparator) - // filter any times according to time range set in config. - .filter((time, i, array) => { - const departureTime = time.serviceDay + time.realtimeDeparture - return isBefore(departureTime, addDays(now, daysAhead)) - }) - // remove excess departure times - .slice(0, numberOfDepartures) - ) +/** Filter any times according to time range set in config. */ +function isWithinDaysAhead(time: Time, now: Date, daysAhead: number) { + const departureTime = time.serviceDay + time.realtimeDeparture + return isBefore(departureTime, addDays(now, daysAhead)) } /** Helper to sort and group stop times by pattern by service day */ @@ -61,35 +48,35 @@ export function groupAndSortStopTimesByPatternByDay( PatternStopTimes > - const patternTimes: PatternDayStopTimes[] = [] - Object.values(stopTimesByPattern) - .filter(hasValidTimesAndRoute) - .forEach((pattern) => { - const sortedTimes = sortAndFilterPatternTimes( - pattern.times, - now, - daysAhead, - numberOfDepartures + return ( + Object.values(stopTimesByPattern) + .filter(hasValidTimesAndRoute) + .map((pattern) => + pattern.times + .concat([]) + .sort(stopTimeComparator) + .filter((time) => isWithinDaysAhead(time, now, daysAhead)) + // remove excess departure times + .slice(0, numberOfDepartures) + // collect times by pattern by day + // (every pattern returned has stop times within the days ahead.) + .reduce>((days, t) => { + const { serviceDay } = t + const patternDay = getOrPutEntry(days, serviceDay, (day) => ({ + ...pattern, + day, + times: [] + })) + patternDay.times.push(t) + return days + }, {}) ) - - const patternDays: Record = {} - sortedTimes.forEach((t: Time) => { - const { serviceDay } = t - let patternDay = patternDays[serviceDay] - if (!patternDay) { - patternDays[serviceDay] = patternDay = { - ...pattern, - day: serviceDay, - times: [] - } - patternTimes.push(patternDay) - } - // Ensures that every pattern returned has stop times within the days ahead. - patternDay.times.push(t) - }) - }) - - // Sort route times by service day then realtime departure - patternTimes.sort(patternComparator) - return patternTimes + // Concatenate all resulting patterns + .reduce( + (result, cur) => result.concat(Object.values(cur)), + [] + ) + // Sort route times by service day then realtime departure + .sort(patternComparator) + ) } From d0df6068c3895d85e7040075d40d365ec99abbf5 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:06:52 -0400 Subject: [PATCH 07/12] refactor(pattern-row): Remove redundant and unused code. --- lib/components/viewers/live-stop-times.tsx | 10 +- lib/components/viewers/pattern-row.tsx | 151 +++++++++------------ 2 files changed, 65 insertions(+), 96 deletions(-) diff --git a/lib/components/viewers/live-stop-times.tsx b/lib/components/viewers/live-stop-times.tsx index 5ec848715..b66436856 100644 --- a/lib/components/viewers/live-stop-times.tsx +++ b/lib/components/viewers/live-stop-times.tsx @@ -13,6 +13,7 @@ import React, { Component } from 'react' import { groupAndSortStopTimesByPatternByDay } from '../../util/stop-times' import { IconWithText } from '../util/styledIcon' +import { StopData } from '../util/types' import FormattedDayOfWeek from '../util/formatted-day-of-week' import SpanWithSpace from '../util/span-with-space' @@ -36,14 +37,12 @@ type Props = { setHoveredStop: (stopId: string) => void showNearbyStops: boolean showOperatorLogo?: boolean - // TODO: shared types - stopData: any + stopData: StopData stopViewerArriving: React.ReactNode // TODO: shared types stopViewerConfig: any toggleAutoRefresh: (enable: boolean) => void - // TODO: shared types - transitOperators: any + transitOperators: TransitOperator[] viewedStop: { stopId: string } } @@ -173,7 +172,6 @@ class LiveStopTimes extends Component { stopViewerConfig.numberOfDepartures ) - console.log('route times', routeTimes) return ( <>
      @@ -199,8 +197,6 @@ class LiveStopTimes extends Component { }} showOperatorLogo={showOperatorLogo} stopTimes={times} - stopViewerArriving={stopViewerArriving} - stopViewerConfig={stopViewerConfig} /> ) diff --git a/lib/components/viewers/pattern-row.tsx b/lib/components/viewers/pattern-row.tsx index 0b4084251..cc1765974 100644 --- a/lib/components/viewers/pattern-row.tsx +++ b/lib/components/viewers/pattern-row.tsx @@ -1,6 +1,5 @@ import { getMostReadableTextColor } from '@opentripplanner/core-utils/lib/route' -import { injectIntl, IntlShape } from 'react-intl' -import React, { Component } from 'react' +import React, { useContext } from 'react' import type { Route, TransitOperator } from '@opentripplanner/types' import { ComponentContext } from '../../util/contexts' @@ -16,107 +15,81 @@ import OperatorLogo from '../util/operator-logo' import StopTimeCell from './stop-time-cell' type Props = { - homeTimezone?: any - intl: IntlShape + homeTimezone?: string pattern: Pattern route: Route & { operator?: TransitOperator & { colorMode?: string } } showOperatorLogo?: boolean stopTimes: Time[] - stopViewerArriving: React.ReactNode - stopViewerConfig: { numberOfDepartures: number } } -type State = { expanded: boolean } + /** * Represents a single pattern row for displaying arrival times in the stop * viewer. */ -class PatternRow extends Component { - constructor(props: Props) { - super(props) - this.state = { expanded: false } - } - - static contextType = ComponentContext +const PatternRow = ({ + homeTimezone, + pattern, + route, + showOperatorLogo, + stopTimes +}: Props): JSX.Element | null => { + // @ts-expect-error FIXME: No type on ComponentContext + const { RouteRenderer: CustomRouteRenderer } = useContext(ComponentContext) + const RouteRenderer = CustomRouteRenderer || DefaultRouteRenderer - _toggleExpandedView = () => { - this.setState({ expanded: !this.state.expanded }) + const hasStopTimes = stopTimes && stopTimes.length > 0 + if (!hasStopTimes) { + return null } - render() { - const { RouteRenderer: CustomRouteRenderer } = this.context - const RouteRenderer = CustomRouteRenderer || DefaultRouteRenderer - const { - homeTimezone, - pattern, - route, - showOperatorLogo, - stopTimes, - stopViewerConfig - } = this.props + const routeName = route.shortName ? route.shortName : route.longName + const routeColor = getRouteColorBasedOnSettings(route.operator, route) - // sort stop times by next departure - let sortedStopTimes: Time[] = [] - const hasStopTimes = stopTimes && stopTimes.length > 0 - if (hasStopTimes) { - sortedStopTimes = stopTimes - // We request only x departures per pattern, but the patterns are merged - // according to shared headsigns, so we need to slice the stop times - // here as well to ensure only x times are shown per route/headsign combo. - .slice(0, stopViewerConfig.numberOfDepartures) - } else { - // Do not render pattern row if it has no stop times. - return null - } - - const routeName = route.shortName ? route.shortName : route.longName - const routeColor = getRouteColorBasedOnSettings(route.operator, route) - - return ( -
    • - {/* header row */} -
      - {/* route name */} -
      - - {showOperatorLogo && } - - - {pattern.headsign} -
      - {/* next departure preview */} - {hasStopTimes && ( -
        - {[0, 1, 2].map( - (index) => - sortedStopTimes?.[index] && ( -
      1. - -
      2. - ) + return ( +
      3. + {/* header row */} +
        + {/* route name */} +
        + + {showOperatorLogo && } + - )} + leg={generateFakeLegForRouteRenderer(route, true)} + style={{ fontSize: routeNameFontSize(routeName) }} + /> + + {pattern.headsign}
        -
      4. - ) - } + {/* next departure preview (only shows up to 3 entries) */} + {hasStopTimes && ( +
          + {[0, 1, 2].map( + (index) => + stopTimes?.[index] && ( +
        1. + +
        2. + ) + )} +
        + )} +
      +
    • + ) } -export default injectIntl(PatternRow) +export default PatternRow From ef0eb9acfe72f93874d21d1d5d2856241426ee38 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:22:12 -0400 Subject: [PATCH 08/12] fix(live-stop-times): Use a unique key with patterns on multiple days. --- lib/components/viewers/live-stop-times.tsx | 48 ++++++++++------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/lib/components/viewers/live-stop-times.tsx b/lib/components/viewers/live-stop-times.tsx index b66436856..f07bc7662 100644 --- a/lib/components/viewers/live-stop-times.tsx +++ b/lib/components/viewers/live-stop-times.tsx @@ -33,7 +33,7 @@ type Props = { findStopTimesForStop: ({ stopId }: { stopId: string }) => void homeTimezone: string intl: IntlShape - nearbyStops: any // TODO: shared types + nearbyStops: string[] setHoveredStop: (stopId: string) => void showNearbyStops: boolean showOperatorLogo?: boolean @@ -175,32 +175,26 @@ class LiveStopTimes extends Component { return ( <>
        - {routeTimes.map((time: any, index: number) => { - const { id, pattern, route, times } = time - return ( - - {((index > 0 && - !isSameDay( - time.day * 1000, - routeTimes[index - 1]?.day * 1000 - )) || - (index === 0 && !isSameDay(now, time.day * 1000))) && - this.renderDay(homeTimezone, time.day, now)} - o.agencyId === route.agencyId - ) - }} - showOperatorLogo={showOperatorLogo} - stopTimes={times} - /> - - ) - })} + {routeTimes.map(({ day, id, pattern, route, times }, index) => ( + + {((index > 0 && + !isSameDay(day * 1000, routeTimes[index - 1]?.day * 1000)) || + (index === 0 && !isSameDay(now, day * 1000))) && + this.renderDay(homeTimezone, day, now)} + o.agencyId === route.agencyId + ) + }} + showOperatorLogo={showOperatorLogo} + stopTimes={times} + /> + + ))}
      {/* Auto update controls for realtime arrivals */} From 1823a1461e131a1c4084122f721182d8abf07102 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:24:22 -0400 Subject: [PATCH 09/12] test: Update snapshots --- .../viewers/__snapshots__/stop-viewer.js.snap | 8153 +++++++---------- 1 file changed, 3454 insertions(+), 4699 deletions(-) diff --git a/__tests__/components/viewers/__snapshots__/stop-viewer.js.snap b/__tests__/components/viewers/__snapshots__/stop-viewer.js.snap index ef900b6da..50ed8f81b 100644 --- a/__tests__/components/viewers/__snapshots__/stop-viewer.js.snap +++ b/__tests__/components/viewers/__snapshots__/stop-viewer.js.snap @@ -1250,7 +1250,7 @@ exports[`components > viewers > stop viewer should render countdown times after
        - viewers > stop viewer should render countdown times after "timepoint": true, "tripId": "TriMet:9230377", }, - Object { - "arrivalDelay": 0, - "blockId": "2067", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 13980, - "realtimeDeparture": 13980, - "realtimeState": "SCHEDULED", - "scheduledArrival": 13980, - "scheduledDeparture": 13980, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230305", - }, - Object { - "arrivalDelay": 0, - "blockId": "2034", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 17580, - "realtimeDeparture": 17580, - "realtimeState": "SCHEDULED", - "scheduledArrival": 17580, - "scheduledDeparture": 17580, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230306", - }, - Object { - "arrivalDelay": 0, - "blockId": "2069", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 19020, - "realtimeDeparture": 19020, - "realtimeState": "SCHEDULED", - "scheduledArrival": 19020, - "scheduledDeparture": 19020, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230307", - }, ] } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } > - +
        -
      • -
        - - + - viewers > stop viewer should render countdown times after } title="20" > - - 20 - - - - - - Gresham TC - -
        -
          + + + + -
        1. - +
        +
          +
        1. + +
          -
          - viewers > stop viewer should render countdown times after } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render countdown times after iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - + + + + + + + + - - - common.time.tripDurationFormat - - - -
          - -
        2. -
        3. - + common.time.tripDurationFormat + + + +
      • + + +
      • + +
        -
        - viewers > stop viewer should render countdown times after } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render countdown times after iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + + - - 1:52 AM - - - -
        - -
      • -
      • - + + + + +
      • +
      • + +
        -
        - viewers > stop viewer should render countdown times after } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render countdown times after iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + + - - 2:53 AM - - - -
        - -
      • - - - -
        -
        + 2:53 AM + + + + + + + + + +
      viewers > stop viewer should render countdown times for st

      - viewers > stop viewer should render countdown times for st }, ] } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } > - +
      -
    • -
      - - + - viewers > stop viewer should render countdown times for st } title="20" > - - 20 - - - - - - Gresham TC - -
      -
        + + + + -
      1. - +
      +
        +
      1. + +
        -
        - viewers > stop viewer should render countdown times for st } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render countdown times for st iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - - common.time.tripDurationFormat - - + /> + + + + -
        - -
      2. -
      -
    • - -
      -
      + + + + + common.time.tripDurationFormat + + + +
      + + + + + +
    viewers > stop viewer should render times after midnight w

    - viewers > stop viewer should render times after midnight w "mode": "BUS", "operator": undefined, "shortName": "20", - "sortOrder": 2600, - "sortOrderSet": true, - "type": 3, - } - } - showOperatorLogo={false} - stopTimes={ - Array [ - Object { - "arrivalDelay": 0, - "blockId": "2041", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 89460, - "realtimeDeparture": 89460, - "realtimeState": "SCHEDULED", - "scheduledArrival": 89460, - "scheduledDeparture": 89460, - "serviceDay": 1565161200, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230375", - }, - Object { - "arrivalDelay": 0, - "blockId": "2043", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 93120, - "realtimeDeparture": 93120, - "realtimeState": "SCHEDULED", - "scheduledArrival": 93120, - "scheduledDeparture": 93120, - "serviceDay": 1565161200, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230376", - }, - Object { - "arrivalDelay": 0, - "blockId": "2049", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 96780, - "realtimeDeparture": 96780, - "realtimeState": "SCHEDULED", - "scheduledArrival": 96780, - "scheduledDeparture": 96780, - "serviceDay": 1565161200, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230377", - }, - Object { - "arrivalDelay": 0, - "blockId": "2067", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 13980, - "realtimeDeparture": 13980, - "realtimeState": "SCHEDULED", - "scheduledArrival": 13980, - "scheduledDeparture": 13980, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230305", - }, - Object { - "arrivalDelay": 0, - "blockId": "2034", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 17580, - "realtimeDeparture": 17580, - "realtimeState": "SCHEDULED", - "scheduledArrival": 17580, - "scheduledDeparture": 17580, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230306", - }, - Object { - "arrivalDelay": 0, - "blockId": "2069", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 19020, - "realtimeDeparture": 19020, - "realtimeState": "SCHEDULED", - "scheduledArrival": 19020, - "scheduledDeparture": 19020, - "serviceDay": 1565247600, - "stopCount": 132, - "stopId": "TriMet:9860", - "stopIndex": 38, - "timepoint": true, - "tripId": "TriMet:9230307", - }, - ] - } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } - > - +
  • -
  • -
    - - + - viewers > stop viewer should render times after midnight w } title="20" > - - 20 - - - - - - Gresham TC - -
    -
      + + + + -
    1. - +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render times after midnight w } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render times after midnight w iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + + - - 12:51 AM - - - -
      - -
    2. -
    3. - + + +
  • + + +
  • + +
    -
    - viewers > stop viewer should render times after midnight w } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render times after midnight w iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + - - 1:52 AM - - - -
    - -
  • -
  • - + + 1:52 AM + + + + + +
  • +
  • + +
    -
    - viewers > stop viewer should render times after midnight w } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render times after midnight w iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + + - - 2:53 AM - - - -
    - -
  • - - - - - + 2:53 AM + + + + + + + + + +
viewers > stop viewer should render with OTP transit index

- viewers > stop viewer should render with OTP transit index "realtimeDeparture": 66668, "realtimeState": "SCHEDULED", "scheduledArrival": 66668, - "scheduledDeparture": 66668, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230360", - }, - Object { - "arrivalDelay": 0, - "blockId": "2048", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 67628, - "realtimeDeparture": 67628, - "realtimeState": "SCHEDULED", - "scheduledArrival": 67628, - "scheduledDeparture": 67628, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230361", - }, - Object { - "arrivalDelay": 0, - "blockId": "2036", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 70028, - "realtimeDeparture": 70028, - "realtimeState": "SCHEDULED", - "scheduledArrival": 70028, - "scheduledDeparture": 70028, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230363", - }, - Object { - "arrivalDelay": 0, - "blockId": "2071", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 72436, - "realtimeDeparture": 72436, - "realtimeState": "SCHEDULED", - "scheduledArrival": 72436, - "scheduledDeparture": 72436, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230365", - }, - ] - } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } - > - +
  • -
  • -
    - - + - viewers > stop viewer should render with OTP transit index } title="20" > - - 20 - - - - - - Gresham TC - -
    -
      + + + + -
    1. - +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 6:00 PM - - - -
      - -
    2. -
    3. - + + +
  • + + +
  • + +
    -
    - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 6:15 PM - - - -
    - -
  • -
  • - + + + + +
  • +
  • + +
    -
    - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 6:31 PM - - - -
    - -
  • - - - - - + 6:31 PM + + + + + + + + + +

    viewers > stop viewer should render with OTP transit index

    - viewers > stop viewer should render with OTP transit index "timepoint": true, "tripId": "TriMet:9238190", }, - Object { - "arrivalDelay": 0, - "blockId": "9474", - "departureDelay": 0, - "headsign": "Sherwood", - "realtime": false, - "realtimeArrival": 56880, - "realtimeDeparture": 56880, - "realtimeState": "SCHEDULED", - "scheduledArrival": 56880, - "scheduledDeparture": 56880, - "serviceDay": 1565074800, - "stopCount": 40, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9238194", - }, - Object { - "arrivalDelay": 0, - "blockId": "9470", - "departureDelay": 0, - "headsign": "Sherwood", - "realtime": false, - "realtimeArrival": 54720, - "realtimeDeparture": 54720, - "realtimeState": "SCHEDULED", - "scheduledArrival": 54720, - "scheduledDeparture": 54720, - "serviceDay": 1565161200, - "stopCount": 34, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9238190", - }, - Object { - "arrivalDelay": 0, - "blockId": "9470", - "departureDelay": 0, - "headsign": "Sherwood", - "realtime": false, - "realtimeArrival": 54720, - "realtimeDeparture": 54720, - "realtimeState": "SCHEDULED", - "scheduledArrival": 54720, - "scheduledDeparture": 54720, - "serviceDay": 1565247600, - "stopCount": 34, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9238190", - }, ] } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } > - +
    -
  • -
    - - + + + 94 + + + + + + Sherwood + +
    +
      +
    1. + +
      + + + + + + + + + + + + + + + + + common.daysOfWeek.tuesday + + + + + + + + 2:28 PM + + + +
      +
      +
    2. +
    3. + +
      - - 94 + + + + + + + - - - - - Sherwood - -
      -
        -
      1. - + + + + + + common.daysOfWeek.tuesday + + + + + + + + 3:02 PM + + + +
    + +
  • +
  • + +
    -
    - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.tuesday - - - - - - + + + + + + - - 2:28 PM - - - -
    - -
  • -
  • - + + +
  • + + + + + +
    + +
  • +
    +
    + + + + + 94 + + + + + + King City + +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - - - - common.daysOfWeek.tuesday - - - - - - - - 3:02 PM - - + /> + + + + -
      - -
    2. -
    3. - -
      + - + - - - - - - - - - - - - - - - common.daysOfWeek.tuesday - - - - - - + + + + + + - - 3:12 PM - - - -
      -
      -
    4. -
    -
    -
  • -
    -
    - + + + + + + + + + + viewers > stop viewer should render with OTP transit index Array [ Object { "arrivalDelay": 0, - "blockId": "9472", + "blockId": "3668", "departureDelay": 0, - "headsign": "King City", + "headsign": "Tualatin Park & Ride", "realtime": false, - "realtimeArrival": 55320, - "realtimeDeparture": 55320, + "realtimeArrival": 58260, + "realtimeDeparture": 58260, "realtimeState": "SCHEDULED", - "scheduledArrival": 55320, - "scheduledDeparture": 55320, + "scheduledArrival": 58260, + "scheduledDeparture": 58260, "serviceDay": 1565074800, - "stopCount": 23, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9238192", - }, - Object { - "arrivalDelay": 0, - "blockId": "9472", - "departureDelay": 0, - "headsign": "King City", - "realtime": false, - "realtimeArrival": 55320, - "realtimeDeparture": 55320, - "realtimeState": "SCHEDULED", - "scheduledArrival": 55320, - "scheduledDeparture": 55320, - "serviceDay": 1565161200, - "stopCount": 23, + "stopCount": 63, "stopId": "TriMet:715", "stopIndex": 0, "timepoint": true, - "tripId": "TriMet:9238192", + "tripId": "TriMet:9231858", }, Object { "arrivalDelay": 0, - "blockId": "9472", + "blockId": "3670", "departureDelay": 0, - "headsign": "King City", + "headsign": "Tualatin Park & Ride", "realtime": false, - "realtimeArrival": 55320, - "realtimeDeparture": 55320, + "realtimeArrival": 61740, + "realtimeDeparture": 61740, "realtimeState": "SCHEDULED", - "scheduledArrival": 55320, - "scheduledDeparture": 55320, - "serviceDay": 1565247600, - "stopCount": 23, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9238192", - }, - ] - } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } - > - +
  • -
  • -
    - - + - + 36 + + + + + + Tualatin Park & Ride + +
    +
      +
    1. + +
      + - 94 + + + + + + + - - - - - King City - -
      -
        -
      1. - + + + + + + common.daysOfWeek.tuesday + + + + + + + + 4:11 PM + + + +
    + +
  • +
  • + +
    -
    - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.tuesday - - - - - - + + + + + + - - 3:22 PM - - - -
    - -
  • -
  • - + + + + +
  • + + + +
    +

    + + + common.daysOfWeek.wednesday + + +

    + +
  • +
    +
    + + + -
    + 94 + + + + + + King City + +
    +
      +
    1. + +
      + - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - - - - common.daysOfWeek.wednesday - - - - - - - - 3:22 PM - - + /> + + + + -
      -
      -
    2. -
    3. - -
      + - + - - - - - - - - - - - - - - - common.daysOfWeek.thursday - - - - - - + + + + + + - - 3:22 PM - - - -
      -
      -
    4. -
    -
    -
  • -
    -
    - + + + + + + + + + + viewers > stop viewer should render with OTP transit index showOperatorLogo={false} stopTimes={ Array [ - Object { - "arrivalDelay": 0, - "blockId": "3668", - "departureDelay": 0, - "headsign": "Tualatin Park & Ride", - "realtime": false, - "realtimeArrival": 58260, - "realtimeDeparture": 58260, - "realtimeState": "SCHEDULED", - "scheduledArrival": 58260, - "scheduledDeparture": 58260, - "serviceDay": 1565074800, - "stopCount": 63, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9231858", - }, - Object { - "arrivalDelay": 0, - "blockId": "3670", - "departureDelay": 0, - "headsign": "Tualatin Park & Ride", - "realtime": false, - "realtimeArrival": 61740, - "realtimeDeparture": 61740, - "realtimeState": "SCHEDULED", - "scheduledArrival": 61740, - "scheduledDeparture": 61740, - "serviceDay": 1565074800, - "stopCount": 63, - "stopId": "TriMet:715", - "stopIndex": 0, - "timepoint": true, - "tripId": "TriMet:9231860", - }, Object { "arrivalDelay": 0, "blockId": "3668", @@ -12261,179 +11402,57 @@ exports[`components > viewers > stop viewer should render with OTP transit index }, ] } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } > - -
  • -
    +
    -
    - - + - viewers > stop viewer should render with OTP transit index } title="36" > - - 36 - - - - - - Tualatin Park & Ride - -
    -
      + + + + -
    1. - +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - - - - common.daysOfWeek.tuesday - - - - - - - - 4:11 PM - - + /> + + + + -
      - -
    2. -
    3. - -
      + - + - - - - - - - - - - - - - - - common.daysOfWeek.tuesday - - - - - - + + + + + + - - 5:09 PM - - - -
      -
      -
    4. -
    5. - + + +
    + +
  • + + + +
    +

    + + + common.daysOfWeek.thursday + + +

    + +
  • +
    +
    + + + + + 94 + + + + + + King City + +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render with OTP transit index } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with OTP transit index iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.wednesday - - - - - - + + + + + + - - 4:11 PM - - - -
      - -
    2. -
    -
    -
  • -
    -
    + 3:22 PM + + + + + + + + + +
    viewers > stop viewer should render with TriMet transit in

    - viewers > stop viewer should render with TriMet transit in "realtimeDeparture": 65759, "realtimeState": "SCHEDULED", "scheduledArrival": 65759, - "scheduledDeparture": 65759, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230359", - }, - Object { - "arrivalDelay": 0, - "blockId": "2047", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 66668, - "realtimeDeparture": 66668, - "realtimeState": "SCHEDULED", - "scheduledArrival": 66668, - "scheduledDeparture": 66668, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230360", - }, - Object { - "arrivalDelay": 0, - "blockId": "2036", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 70028, - "realtimeDeparture": 70028, - "realtimeState": "SCHEDULED", - "scheduledArrival": 70028, - "scheduledDeparture": 70028, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230363", - }, - Object { - "arrivalDelay": 0, - "blockId": "2071", - "departureDelay": 0, - "headsign": "Gresham TC", - "realtime": false, - "realtimeArrival": 72436, - "realtimeDeparture": 72436, - "realtimeState": "SCHEDULED", - "scheduledArrival": 72436, - "scheduledDeparture": 72436, - "serviceDay": 1564988400, - "stopCount": 132, - "stopId": "TriMet:715", - "stopIndex": 42, - "timepoint": false, - "tripId": "TriMet:9230365", - }, - ] - } - stopViewerConfig={ - Object { - "nearbyRadius": 250, - "numberOfDepartures": 3, - "showBlockIds": false, - "timeRange": 172800, - } - } - > - +
  • -
  • -
    - - + - viewers > stop viewer should render with TriMet transit in } title="20" > - - 20 - - - - - - Gresham TC - -
    -
      + + + + -
    1. - +
    +
      +
    1. + +
      -
      - viewers > stop viewer should render with TriMet transit in } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with TriMet transit in iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 5:45 PM - - - -
      - -
    2. -
    3. - + + +
  • + + +
  • + +
    -
    - viewers > stop viewer should render with TriMet transit in } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with TriMet transit in iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 6:00 PM - - - -
    - -
  • -
  • - + + + + +
  • +
  • + +
    -
    - viewers > stop viewer should render with TriMet transit in } title="components.StopTimeCell.scheduled" > - + - - + viewers > stop viewer should render with TriMet transit in iconVerticalAlign="middle" iconViewBox="0 0 512 512" > - - - - - - - - + + + + + + + + + + - - - common.daysOfWeek.monday - - - - - - + + + + + + - - 6:15 PM - - - -
    - -
  • - - - - - + 6:15 PM + + + + + + + + + +
    Date: Thu, 21 Sep 2023 09:06:49 -0400 Subject: [PATCH 10/12] ci(codespell): Exclude /__tests__/mocks --- .github/workflows/codespell.yml | 2 +- __tests__/{util => mocks}/stop-data.json | 0 __tests__/util/stop-times.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename __tests__/{util => mocks}/stop-data.json (100%) diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index 7206755e7..cfc31658b 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -15,4 +15,4 @@ jobs: # skip git, yarn, pixel test script and HAR file, and all i18n resources. # Also, the a11y test file has a false positive and the ignore list does not work # see https://github.com/opentripplanner/otp-react-redux/pull/436/checks?check_run_id=3369380014 - skip: ./.git,yarn.lock,./a11y/a11y.test.js,./a11y/mocks,./percy/percy.test.js,./percy/mock.har,./i18n + skip: ./.git,yarn.lock,./a11y/a11y.test.js,./a11y/mocks,./percy/percy.test.js,./percy/mock.har,./i18n,./__tests__/mocks diff --git a/__tests__/util/stop-data.json b/__tests__/mocks/stop-data.json similarity index 100% rename from __tests__/util/stop-data.json rename to __tests__/mocks/stop-data.json diff --git a/__tests__/util/stop-times.ts b/__tests__/util/stop-times.ts index 6d6ef8fb2..92bbc0170 100644 --- a/__tests__/util/stop-times.ts +++ b/__tests__/util/stop-times.ts @@ -3,7 +3,7 @@ import { utcToZonedTime } from 'date-fns-tz' import '../test-utils/mock-window-url' import { groupAndSortStopTimesByPatternByDay } from '../../lib/util/stop-times' -const stopData = require('./stop-data.json') +const stopData = require('../mocks/stop-data.json') const now = utcToZonedTime( new Date(stopData.stopTimesLastUpdated), 'America/Los_Angeles' From 168e65f7a4a237920bcf3d7802d0f214e0e92d90 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Thu, 28 Sep 2023 14:57:33 -0400 Subject: [PATCH 11/12] clean up call taker settings --- lib/components/form/call-taker/advanced-options.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/components/form/call-taker/advanced-options.js b/lib/components/form/call-taker/advanced-options.js index dcf81ee32..d1b66277c 100644 --- a/lib/components/form/call-taker/advanced-options.js +++ b/lib/components/form/call-taker/advanced-options.js @@ -39,6 +39,8 @@ export const StyledSubmodeSelector = styled(SubmodeSelector)` ${TripFormClasses.SubmodeSelector} { ${modeButtonButtonCss} } + + margin: 5px 0; ` const metersToMiles = (meters) => Math.round(meters * 0.000621371 * 100) / 100 @@ -207,7 +209,7 @@ class AdvancedOptions extends Component { const Select = lazy(() => import('react-select')) - const { bikeTolerance, modes: currentModes, walkReluctance } = currentQuery + const { modes: currentModes } = currentQuery const bannedRoutes = this.getRouteList('banned') const preferredRoutes = this.getRouteList('preferred') const transitModes = modes.transitModes.map((modeObj) => { @@ -223,7 +225,7 @@ class AdvancedOptions extends Component {
    Date: Mon, 2 Oct 2023 19:49:03 -0400 Subject: [PATCH 12/12] docs: Fix typos --- lib/components/viewers/next-arrival-for-pattern.tsx | 2 +- lib/util/viewer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/viewers/next-arrival-for-pattern.tsx b/lib/components/viewers/next-arrival-for-pattern.tsx index 2fceb4cf8..bed35582c 100644 --- a/lib/components/viewers/next-arrival-for-pattern.tsx +++ b/lib/components/viewers/next-arrival-for-pattern.tsx @@ -21,7 +21,7 @@ type Props = { pattern: Pattern // Not the true operator type, but the one that's used here // It is annoying to shoehorn the operator in here like this, but passing - // it in indvidually would cause a situation where a list of routes + // it in individually would cause a situation where a list of routes // needs to be matched up with a list of operators route: Route & { operator?: { colorMode?: string } } routeColor: string diff --git a/lib/util/viewer.js b/lib/util/viewer.js index bdb27b3cb..9f1f9ef9d 100644 --- a/lib/util/viewer.js +++ b/lib/util/viewer.js @@ -40,7 +40,7 @@ function excludeLastStop(stopTime) { * Checks that the given route object from an OTP pattern is valid. * If it is not, logs a warning message. * - * FIXME: there is currently a bug with the alernative transit index + * FIXME: there is currently a bug with the alternative transit index * where routes are not associated with the stop if the only stoptimes * for the stop are drop off only. See https://github.com/ibi-group/trimet-mod-otp/issues/217 *