From 1c7ee9fbc369576c093f2c2b8f23fe5cc776c653 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 29 Apr 2025 17:05:23 -0700 Subject: [PATCH] change all millisecond references into Dates --- .../ChapmanApiBasedParkingRepositoryLoader.ts | 2 +- src/loaders/parking/loadParkingTestData.ts | 4 +-- .../ApiBasedShuttleRepositoryLoader.ts | 14 ++++---- src/loaders/shuttle/loadShuttleTestData.ts | 32 ++++++++--------- src/resolvers/RouteResolvers.ts | 6 ++-- ...iBasedParkingRepositoryLoaderTests.test.ts | 4 +-- .../ETANotificationSchedulerTests.test.ts | 2 +- .../InMemoryParkingRepositoryTests.test.ts | 2 +- test/testHelpers/mockDataGenerators.ts | 36 +++++++++---------- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/loaders/parking/ChapmanApiBasedParkingRepositoryLoader.ts b/src/loaders/parking/ChapmanApiBasedParkingRepositoryLoader.ts index 1c08a06..5cfafea 100644 --- a/src/loaders/parking/ChapmanApiBasedParkingRepositoryLoader.ts +++ b/src/loaders/parking/ChapmanApiBasedParkingRepositoryLoader.ts @@ -59,7 +59,7 @@ export class ChapmanApiBasedParkingRepositoryLoader implements ParkingRepository name: jsonStructure.Name, spotsAvailable: jsonStructure.CurrentCount > jsonStructure.Capacity ? jsonStructure.Capacity : jsonStructure.CurrentCount, address: jsonStructure.Address, - updatedTime: Date.now(), + updatedTime: new Date(), } return structureToReturn; diff --git a/src/loaders/parking/loadParkingTestData.ts b/src/loaders/parking/loadParkingTestData.ts index d117ab8..be7663d 100644 --- a/src/loaders/parking/loadParkingTestData.ts +++ b/src/loaders/parking/loadParkingTestData.ts @@ -12,7 +12,7 @@ const parkingStructures: IParkingStructure[] = [ }, name: "Anderson Structure", id: "1", - updatedTime: Date.now(), + updatedTime: new Date(), }, { address: "200 W Sycamore Ave, Orange, CA 92866-1053", @@ -24,7 +24,7 @@ const parkingStructures: IParkingStructure[] = [ }, name: "Barrera", id: "2", - updatedTime: Date.now(), + updatedTime: new Date(), } ]; diff --git a/src/loaders/shuttle/ApiBasedShuttleRepositoryLoader.ts b/src/loaders/shuttle/ApiBasedShuttleRepositoryLoader.ts index 95cbdc2..c7735aa 100644 --- a/src/loaders/shuttle/ApiBasedShuttleRepositoryLoader.ts +++ b/src/loaders/shuttle/ApiBasedShuttleRepositoryLoader.ts @@ -73,7 +73,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader id: jsonRoute.myid, polylineCoordinates: [], systemId: this.systemIdForConstructedData, - updatedTime: Date.now(), + updatedTime: new Date(), }; await this.repository.addOrUpdateRoute(constructedRoute); @@ -174,7 +174,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader systemId: this.systemIdForConstructedData, id: `${jsonBus.busId}`, orientationInDegrees: parseFloat(jsonBus.calculatedCourse), - updatedTime: Date.now(), + updatedTime: new Date(), } await this.repository.addOrUpdateShuttle(constructedShuttle); @@ -223,7 +223,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader secondsRemaining: jsonEta.secondsSpent, shuttleId: `${shuttleId}`, stopId: stopId, - updatedTime: Date.now(), + updatedTime: new Date(), systemId: this.systemIdForConstructedData, }; @@ -251,7 +251,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader latitude: parseFloat(stop.latitude), longitude: parseFloat(stop.longitude), }, - updatedTime: Date.now(), + updatedTime: new Date(), }; await this.repository.addOrUpdateStop(constructedStop); @@ -283,7 +283,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader stopId, position: index + 1, systemId: this.systemIdForConstructedData, - updatedTime: Date.now(), + updatedTime: new Date(), }; } @@ -293,7 +293,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader stopId: jsonOrderedStopData[index - 1][1], position: index, systemId: this.systemIdForConstructedData, - updatedTime: Date.now(), + updatedTime: new Date(), }; } if (index < jsonOrderedStopData.length - 1) { @@ -302,7 +302,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader stopId: jsonOrderedStopData[index + 1][1], position: index + 2, systemId: this.systemIdForConstructedData, - updatedTime: Date.now(), + updatedTime: new Date(), }; } diff --git a/src/loaders/shuttle/loadShuttleTestData.ts b/src/loaders/shuttle/loadShuttleTestData.ts index 5b52402..782962d 100644 --- a/src/loaders/shuttle/loadShuttleTestData.ts +++ b/src/loaders/shuttle/loadShuttleTestData.ts @@ -4324,7 +4324,7 @@ const routes: IRoute[] = [ systemId: supportedIntegrationTestSystems[0].id, polylineCoordinates: redRoutePolylineCoordinates, color: "#db2316", - updatedTime: Date.now(), + updatedTime: new Date(), }, { name: "Teal Route", @@ -4332,7 +4332,7 @@ const routes: IRoute[] = [ systemId: supportedIntegrationTestSystems[0].id, polylineCoordinates: tealRoutePolylineCoordinates, color: "#21bdd1", - updatedTime: Date.now(), + updatedTime: new Date(), }, ]; @@ -4345,7 +4345,7 @@ const stops: IStop[] = [ longitude: -117.8892805, }, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { id: "2", @@ -4355,7 +4355,7 @@ const stops: IStop[] = [ longitude: -117.895966, }, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { id: "3", @@ -4365,7 +4365,7 @@ const stops: IStop[] = [ "longitude": -117.85281 }, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), } ]; @@ -4375,14 +4375,14 @@ const orderedStopsForRedRoute: IOrderedStop[] = [ stopId: stops[0].id, position: 1, systemId: "1", - updatedTime: Date.now(), + updatedTime: new Date(), }, { routeId: routes[0].id, stopId: stops[2].id, position: 2, systemId: "1", - updatedTime: Date.now(), + updatedTime: new Date(), }, ]; @@ -4392,21 +4392,21 @@ const orderedStopsForTealRoute: IOrderedStop[] = [ stopId: stops[0].id, position: 1, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { routeId: routes[1].id, stopId: stops[1].id, position: 2, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { routeId: routes[1].id, stopId: stops[2].id, position: 2, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, ] @@ -4426,7 +4426,7 @@ const shuttles: IShuttle[] = [ routeId: routes[0].id, systemId: supportedIntegrationTestSystems[0].id, orientationInDegrees: 45.91, - updatedTime: Date.now(), + updatedTime: new Date(), }, { name: "24", @@ -4438,7 +4438,7 @@ const shuttles: IShuttle[] = [ routeId: routes[0].id, systemId: supportedIntegrationTestSystems[0].id, orientationInDegrees: 90.24, - updatedTime: Date.now(), + updatedTime: new Date(), } ]; @@ -4448,28 +4448,28 @@ const etas: IEta[] = [ shuttleId: shuttles[0].id, secondsRemaining: 12.023, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { stopId: stops[2].id, shuttleId: shuttles[0].id, secondsRemaining: 600.123, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { stopId: stops[2].id, shuttleId: shuttles[1].id, secondsRemaining: 172.015, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), }, { stopId: stops[0].id, shuttleId: shuttles[1].id, secondsRemaining: 710.152, systemId: supportedIntegrationTestSystems[0].id, - updatedTime: Date.now(), + updatedTime: new Date(), } ]; diff --git a/src/resolvers/RouteResolvers.ts b/src/resolvers/RouteResolvers.ts index d24e992..43f6c53 100644 --- a/src/resolvers/RouteResolvers.ts +++ b/src/resolvers/RouteResolvers.ts @@ -3,7 +3,7 @@ import { ServerContext } from "../ServerContext"; export const RouteResolvers: Resolvers = { Route: { - shuttles: async (parent, args, contextValue, info) => { + shuttles: async (parent, args, contextValue, _info) => { const system = contextValue.findSystemById(parent.systemId); if (!system) return null; @@ -23,10 +23,10 @@ export const RouteResolvers: Resolvers = { id, orientationInDegrees, systemId: parent.systemId, - updatedTime: updatedTimeMs, + updatedTime, })); }, - orderedStop: async (parent, args, contextValue, info) => { + orderedStop: async (parent, args, contextValue, _info) => { if (!args.forStopId) return null; const system = contextValue.findSystemById(parent.systemId); diff --git a/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts b/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts index 02012bb..ecd6a12 100644 --- a/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts +++ b/test/loaders/parking/ChapmanApiBasedParkingRepositoryLoaderTests.test.ts @@ -59,7 +59,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => { }, name: "Anderson Structure", id: "", - updatedTime: Date.now(), + updatedTime: new Date(), }, { address: "200 W Sycamore Ave, Orange, CA 92866-1053", @@ -71,7 +71,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => { }, name: "Barrera", id: "", - updatedTime: Date.now(), + updatedTime: new Date(), } ]; expectedStructures[0].id = ChapmanApiBasedParkingRepositoryLoader.generateId(expectedStructures[0].address); diff --git a/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts b/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts index 229dc22..1c5b819 100644 --- a/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts +++ b/test/notifications/schedulers/ETANotificationSchedulerTests.test.ts @@ -52,7 +52,7 @@ describe("ETANotificationScheduler", () => { stopId: stop.id, secondsRemaining: 120, systemId: "1", - updatedTime: Date.now(), + updatedTime: new Date(), }; const notificationData1 = { diff --git a/test/repositories/InMemoryParkingRepositoryTests.test.ts b/test/repositories/InMemoryParkingRepositoryTests.test.ts index ece527b..d358d14 100644 --- a/test/repositories/InMemoryParkingRepositoryTests.test.ts +++ b/test/repositories/InMemoryParkingRepositoryTests.test.ts @@ -14,7 +14,7 @@ describe("InMemoryParkingRepository", () => { name: "Anderson Parking Structure", capacity: 100, address: "300 E Walnut Ave, Orange, CA 92867", - updatedTime: Date.now(), + updatedTime: new Date(), }; beforeEach(() => { diff --git a/test/testHelpers/mockDataGenerators.ts b/test/testHelpers/mockDataGenerators.ts index 7e237e8..dea9037 100644 --- a/test/testHelpers/mockDataGenerators.ts +++ b/test/testHelpers/mockDataGenerators.ts @@ -17,7 +17,7 @@ export function generateParkingStructures(): IParkingStructure[] { "name": "Anderson Structure", "spotsAvailable": 163, "address": "300 E Walnut, Orange, CA 92867", - updatedTime: Date.now(), + updatedTime: new Date(), }, { "capacity": 692, @@ -29,7 +29,7 @@ export function generateParkingStructures(): IParkingStructure[] { "name": "Barrera", "spotsAvailable": 179, "address": "200 W Sycamore Ave, Orange, CA 92866-1053", - updatedTime: Date.now(), + updatedTime: new Date(), } ]; } @@ -46,7 +46,7 @@ export function generateMockShuttles(): IShuttle[] { longitude: 20 }, orientationInDegrees: 25.163, - updatedTime: Date.now(), + updatedTime: new Date(), }, { id: "sh2", @@ -58,7 +58,7 @@ export function generateMockShuttles(): IShuttle[] { longitude: 25 }, orientationInDegrees: 50.912, - updatedTime: Date.now(), + updatedTime: new Date(), }, { id: "sh3", @@ -70,40 +70,40 @@ export function generateMockShuttles(): IShuttle[] { longitude: 40 }, orientationInDegrees: 321.019, - updatedTime: Date.now(), + updatedTime: new Date(), }, ]; } export function generateMockRoutes(): IRoute[] { return [ - { id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [], updatedTime: Date.now() }, - { id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [], updatedTime: Date.now() }, - { id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [], updatedTime: Date.now() }, + { id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [], updatedTime: new Date() }, + { id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [], updatedTime: new Date() }, + { id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [], updatedTime: new Date() }, ]; } export function generateMockStops(): IStop[] { return [ - { id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 }, updatedTime: Date.now() }, - { id: "st2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 }, updatedTime: Date.now() }, - { id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 }, updatedTime: Date.now() }, + { id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 }, updatedTime: new Date() }, + { id: "st2", name: "Stop B", systemId: "sys2", coordinates: { latitude: 15, longitude: 25 }, updatedTime: new Date() }, + { id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 }, updatedTime: new Date() }, ]; } export function generateMockOrderedStops(): IOrderedStop[] { return [ - { stopId: "st1", routeId: "r1", position: 1, systemId: "sys1", updatedTime: Date.now(), }, - { stopId: "st1", routeId: "r2", position: 2, systemId: "sys1", updatedTime: Date.now(), }, - { stopId: "st2", routeId: "r1", position: 3, systemId: "sys1", updatedTime: Date.now(), }, - { stopId: "st2", routeId: "r2", position: 4, systemId: "sys1", updatedTime: Date.now(), }, + { stopId: "st1", routeId: "r1", position: 1, systemId: "sys1", updatedTime: new Date(), }, + { stopId: "st1", routeId: "r2", position: 2, systemId: "sys1", updatedTime: new Date(), }, + { stopId: "st2", routeId: "r1", position: 3, systemId: "sys1", updatedTime: new Date(), }, + { stopId: "st2", routeId: "r2", position: 4, systemId: "sys1", updatedTime: new Date(), }, ]; } export function generateMockEtas(): IEta[] { return [ - { shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1", updatedTime: Date.now() }, - { shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1", updatedTime: Date.now() }, - { shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1", updatedTime: Date.now() }, + { shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1", updatedTime: new Date() }, + { shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1", updatedTime: new Date() }, + { shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1", updatedTime: new Date() }, ]; }