change updatedTime into a Date

This commit is contained in:
2025-04-29 17:01:51 -07:00
parent f68dad0ca2
commit b58babc7ea
13 changed files with 62 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
export interface IEntityWithTimestamp { export interface IEntityWithTimestamp {
updatedTimeMs: number; updatedTime: Date;
} }
export interface IEntityWithId { export interface IEntityWithId {

View File

@@ -59,7 +59,7 @@ export class ChapmanApiBasedParkingRepositoryLoader implements ParkingRepository
name: jsonStructure.Name, name: jsonStructure.Name,
spotsAvailable: jsonStructure.CurrentCount > jsonStructure.Capacity ? jsonStructure.Capacity : jsonStructure.CurrentCount, spotsAvailable: jsonStructure.CurrentCount > jsonStructure.Capacity ? jsonStructure.Capacity : jsonStructure.CurrentCount,
address: jsonStructure.Address, address: jsonStructure.Address,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
return structureToReturn; return structureToReturn;

View File

@@ -12,7 +12,7 @@ const parkingStructures: IParkingStructure[] = [
}, },
name: "Anderson Structure", name: "Anderson Structure",
id: "1", id: "1",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
address: "200 W Sycamore Ave, Orange, CA 92866-1053", address: "200 W Sycamore Ave, Orange, CA 92866-1053",
@@ -24,7 +24,7 @@ const parkingStructures: IParkingStructure[] = [
}, },
name: "Barrera", name: "Barrera",
id: "2", id: "2",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];

View File

@@ -73,7 +73,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
id: jsonRoute.myid, id: jsonRoute.myid,
polylineCoordinates: [], polylineCoordinates: [],
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
await this.repository.addOrUpdateRoute(constructedRoute); await this.repository.addOrUpdateRoute(constructedRoute);
@@ -174,7 +174,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
id: `${jsonBus.busId}`, id: `${jsonBus.busId}`,
orientationInDegrees: parseFloat(jsonBus.calculatedCourse), orientationInDegrees: parseFloat(jsonBus.calculatedCourse),
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
await this.repository.addOrUpdateShuttle(constructedShuttle); await this.repository.addOrUpdateShuttle(constructedShuttle);
@@ -223,7 +223,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
secondsRemaining: jsonEta.secondsSpent, secondsRemaining: jsonEta.secondsSpent,
shuttleId: `${shuttleId}`, shuttleId: `${shuttleId}`,
stopId: stopId, stopId: stopId,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
}; };
@@ -251,7 +251,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
latitude: parseFloat(stop.latitude), latitude: parseFloat(stop.latitude),
longitude: parseFloat(stop.longitude), longitude: parseFloat(stop.longitude),
}, },
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
await this.repository.addOrUpdateStop(constructedStop); await this.repository.addOrUpdateStop(constructedStop);
@@ -283,7 +283,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
stopId, stopId,
position: index + 1, position: index + 1,
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
} }
@@ -293,7 +293,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
stopId: jsonOrderedStopData[index - 1][1], stopId: jsonOrderedStopData[index - 1][1],
position: index, position: index,
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
} }
if (index < jsonOrderedStopData.length - 1) { if (index < jsonOrderedStopData.length - 1) {
@@ -302,7 +302,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
stopId: jsonOrderedStopData[index + 1][1], stopId: jsonOrderedStopData[index + 1][1],
position: index + 2, position: index + 2,
systemId: this.systemIdForConstructedData, systemId: this.systemIdForConstructedData,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
} }

View File

@@ -4324,7 +4324,7 @@ const routes: IRoute[] = [
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
polylineCoordinates: redRoutePolylineCoordinates, polylineCoordinates: redRoutePolylineCoordinates,
color: "#db2316", color: "#db2316",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
name: "Teal Route", name: "Teal Route",
@@ -4332,7 +4332,7 @@ const routes: IRoute[] = [
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
polylineCoordinates: tealRoutePolylineCoordinates, polylineCoordinates: tealRoutePolylineCoordinates,
color: "#21bdd1", color: "#21bdd1",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
]; ];
@@ -4345,7 +4345,7 @@ const stops: IStop[] = [
longitude: -117.8892805, longitude: -117.8892805,
}, },
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
id: "2", id: "2",
@@ -4355,7 +4355,7 @@ const stops: IStop[] = [
longitude: -117.895966, longitude: -117.895966,
}, },
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
id: "3", id: "3",
@@ -4365,7 +4365,7 @@ const stops: IStop[] = [
"longitude": -117.85281 "longitude": -117.85281
}, },
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];
@@ -4375,14 +4375,14 @@ const orderedStopsForRedRoute: IOrderedStop[] = [
stopId: stops[0].id, stopId: stops[0].id,
position: 1, position: 1,
systemId: "1", systemId: "1",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
routeId: routes[0].id, routeId: routes[0].id,
stopId: stops[2].id, stopId: stops[2].id,
position: 2, position: 2,
systemId: "1", systemId: "1",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
]; ];
@@ -4392,21 +4392,21 @@ const orderedStopsForTealRoute: IOrderedStop[] = [
stopId: stops[0].id, stopId: stops[0].id,
position: 1, position: 1,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
routeId: routes[1].id, routeId: routes[1].id,
stopId: stops[1].id, stopId: stops[1].id,
position: 2, position: 2,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
routeId: routes[1].id, routeId: routes[1].id,
stopId: stops[2].id, stopId: stops[2].id,
position: 2, position: 2,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
] ]
@@ -4426,7 +4426,7 @@ const shuttles: IShuttle[] = [
routeId: routes[0].id, routeId: routes[0].id,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
orientationInDegrees: 45.91, orientationInDegrees: 45.91,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
name: "24", name: "24",
@@ -4438,7 +4438,7 @@ const shuttles: IShuttle[] = [
routeId: routes[0].id, routeId: routes[0].id,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
orientationInDegrees: 90.24, orientationInDegrees: 90.24,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];
@@ -4448,28 +4448,28 @@ const etas: IEta[] = [
shuttleId: shuttles[0].id, shuttleId: shuttles[0].id,
secondsRemaining: 12.023, secondsRemaining: 12.023,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
stopId: stops[2].id, stopId: stops[2].id,
shuttleId: shuttles[0].id, shuttleId: shuttles[0].id,
secondsRemaining: 600.123, secondsRemaining: 600.123,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
stopId: stops[2].id, stopId: stops[2].id,
shuttleId: shuttles[1].id, shuttleId: shuttles[1].id,
secondsRemaining: 172.015, secondsRemaining: 172.015,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
stopId: stops[0].id, stopId: stops[0].id,
shuttleId: shuttles[1].id, shuttleId: shuttles[1].id,
secondsRemaining: 710.152, secondsRemaining: 710.152,
systemId: supportedIntegrationTestSystems[0].id, systemId: supportedIntegrationTestSystems[0].id,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];

View File

@@ -24,7 +24,7 @@ export const OrderedStopResolvers: Resolvers<ServerContext> = {
routeId: parent.routeId, routeId: parent.routeId,
stopId: nextOrderedStopObject.id, stopId: nextOrderedStopObject.id,
systemId: system.id, systemId: system.id,
updatedTime: nextOrderedStopObject.updatedTimeMs updatedTime: nextOrderedStopObject.updatedTime
} }
}, },
previousStop: async (parent, args, contextValue, _info): Promise<OrderedStop | null> => { previousStop: async (parent, args, contextValue, _info): Promise<OrderedStop | null> => {
@@ -48,7 +48,7 @@ export const OrderedStopResolvers: Resolvers<ServerContext> = {
routeId: parent.routeId, routeId: parent.routeId,
stopId: previousOrderedStopObject.id, stopId: previousOrderedStopObject.id,
systemId: system.id, systemId: system.id,
updatedTime: previousOrderedStopObject.updatedTimeMs, updatedTime: previousOrderedStopObject.updatedTime,
} }
}, },
stop: async (parent, args, contextValue, _info) => { stop: async (parent, args, contextValue, _info) => {

View File

@@ -14,7 +14,7 @@ export const RouteResolvers: Resolvers<ServerContext> = {
name, name,
id, id,
orientationInDegrees, orientationInDegrees,
updatedTimeMs updatedTime
}) => ({ }) => ({
coordinates: coordinates as Coordinates, coordinates: coordinates as Coordinates,
name, name,
@@ -23,7 +23,7 @@ export const RouteResolvers: Resolvers<ServerContext> = {
id, id,
orientationInDegrees, orientationInDegrees,
systemId: parent.systemId, systemId: parent.systemId,
updatedTimeMs, updatedTime: updatedTimeMs,
})); }));
}, },
orderedStop: async (parent, args, contextValue, info) => { orderedStop: async (parent, args, contextValue, info) => {
@@ -43,7 +43,7 @@ export const RouteResolvers: Resolvers<ServerContext> = {
routeId: parent.id, routeId: parent.id,
route: parent, route: parent,
systemId: system.id, systemId: system.id,
updatedTimeMs: orderedStop.updatedTimeMs, updatedTimeMs: orderedStop.updatedTime,
} }
}, },
}, },

View File

@@ -18,7 +18,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
shuttleId: parent.id, shuttleId: parent.id,
shuttle: parent, shuttle: parent,
systemId: system.id, systemId: system.id,
updatedTimeMs: etaForStopId.updatedTimeMs, updatedTimeMs: etaForStopId.updatedTime,
}; };
}, },
etas: async (parent, args, contextValue, info) => { etas: async (parent, args, contextValue, info) => {
@@ -32,7 +32,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
etasForShuttle.map(async ({ etasForShuttle.map(async ({
secondsRemaining, secondsRemaining,
stopId, stopId,
updatedTimeMs updatedTime
}): Promise<Eta | null> => { }): Promise<Eta | null> => {
return { return {
secondsRemaining, secondsRemaining,
@@ -40,7 +40,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
shuttle: parent, shuttle: parent,
shuttleId: parent.id, shuttleId: parent.id,
systemId: system.id, systemId: system.id,
updatedTime: updatedTimeMs, updatedTime: updatedTime,
} }
})); }));
@@ -63,7 +63,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
name: route.name, name: route.name,
polylineCoordinates: route.polylineCoordinates, polylineCoordinates: route.polylineCoordinates,
systemId: system.id, systemId: system.id,
updatedTimeMs: route.updatedTimeMs updatedTimeMs: route.updatedTime
} }
} }
}, },

View File

@@ -36,7 +36,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
name: stop.name, name: stop.name,
coordinates: stop.coordinates as Coordinates, coordinates: stop.coordinates as Coordinates,
systemId: parent.id, systemId: parent.id,
updatedTimeMs: stop.updatedTimeMs, updatedTimeMs: stop.updatedTime,
}; };
}, },
route: async (parent, args, contextValue, _info) => { route: async (parent, args, contextValue, _info) => {
@@ -56,7 +56,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
name: route.name, name: route.name,
polylineCoordinates: route.polylineCoordinates as Coordinates[], polylineCoordinates: route.polylineCoordinates as Coordinates[],
systemId: parent.id, systemId: parent.id,
updatedTimeMs: route.updatedTimeMs, updatedTimeMs: route.updatedTime,
}; };
}, },
shuttle: async (parent, args, contextValue, _info) => { shuttle: async (parent, args, contextValue, _info) => {

View File

@@ -59,7 +59,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => {
}, },
name: "Anderson Structure", name: "Anderson Structure",
id: "", id: "",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
address: "200 W Sycamore Ave, Orange, CA 92866-1053", address: "200 W Sycamore Ave, Orange, CA 92866-1053",
@@ -71,7 +71,7 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => {
}, },
name: "Barrera", name: "Barrera",
id: "", id: "",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];
expectedStructures[0].id = ChapmanApiBasedParkingRepositoryLoader.generateId(expectedStructures[0].address); expectedStructures[0].id = ChapmanApiBasedParkingRepositoryLoader.generateId(expectedStructures[0].address);
@@ -80,8 +80,8 @@ describe("ChapmanApiBasedParkingRepositoryLoader", () => {
const structuresFromLoader = await loader.repository.getParkingStructures(); const structuresFromLoader = await loader.repository.getParkingStructures();
// Set updatedTimeMs on expected data to avoid comparison // Set updatedTimeMs on expected data to avoid comparison
expectedStructures[0].updatedTimeMs = structuresFromLoader[0].updatedTimeMs; expectedStructures[0].updatedTime = structuresFromLoader[0].updatedTime;
expectedStructures[1].updatedTimeMs = structuresFromLoader[1].updatedTimeMs; expectedStructures[1].updatedTime = structuresFromLoader[1].updatedTime;
expect(structuresFromLoader).toEqual(expectedStructures); expect(structuresFromLoader).toEqual(expectedStructures);
}); });

View File

@@ -52,7 +52,7 @@ describe("ETANotificationScheduler", () => {
stopId: stop.id, stopId: stop.id,
secondsRemaining: 120, secondsRemaining: 120,
systemId: "1", systemId: "1",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
const notificationData1 = { const notificationData1 = {

View File

@@ -14,7 +14,7 @@ describe("InMemoryParkingRepository", () => {
name: "Anderson Parking Structure", name: "Anderson Parking Structure",
capacity: 100, capacity: 100,
address: "300 E Walnut Ave, Orange, CA 92867", address: "300 E Walnut Ave, Orange, CA 92867",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}; };
beforeEach(() => { beforeEach(() => {

View File

@@ -17,7 +17,7 @@ export function generateParkingStructures(): IParkingStructure[] {
"name": "Anderson Structure", "name": "Anderson Structure",
"spotsAvailable": 163, "spotsAvailable": 163,
"address": "300 E Walnut, Orange, CA 92867", "address": "300 E Walnut, Orange, CA 92867",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
"capacity": 692, "capacity": 692,
@@ -29,7 +29,7 @@ export function generateParkingStructures(): IParkingStructure[] {
"name": "Barrera", "name": "Barrera",
"spotsAvailable": 179, "spotsAvailable": 179,
"address": "200 W Sycamore Ave, Orange, CA 92866-1053", "address": "200 W Sycamore Ave, Orange, CA 92866-1053",
updatedTimeMs: Date.now(), updatedTime: Date.now(),
} }
]; ];
} }
@@ -46,7 +46,7 @@ export function generateMockShuttles(): IShuttle[] {
longitude: 20 longitude: 20
}, },
orientationInDegrees: 25.163, orientationInDegrees: 25.163,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
id: "sh2", id: "sh2",
@@ -58,7 +58,7 @@ export function generateMockShuttles(): IShuttle[] {
longitude: 25 longitude: 25
}, },
orientationInDegrees: 50.912, orientationInDegrees: 50.912,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
{ {
id: "sh3", id: "sh3",
@@ -70,40 +70,40 @@ export function generateMockShuttles(): IShuttle[] {
longitude: 40 longitude: 40
}, },
orientationInDegrees: 321.019, orientationInDegrees: 321.019,
updatedTimeMs: Date.now(), updatedTime: Date.now(),
}, },
]; ];
} }
export function generateMockRoutes(): IRoute[] { export function generateMockRoutes(): IRoute[] {
return [ return [
{ id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [], updatedTimeMs: Date.now() }, { id: "r1", name: "Route 1", color: "red", systemId: "sys1", polylineCoordinates: [], updatedTime: Date.now() },
{ id: "r2", name: "Route 2", color: "blue", systemId: "sys2", polylineCoordinates: [], updatedTimeMs: 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: [], updatedTimeMs: Date.now() }, { id: "r3", name: "Route 3", color: "green", systemId: "sys3", polylineCoordinates: [], updatedTime: Date.now() },
]; ];
} }
export function generateMockStops(): IStop[] { export function generateMockStops(): IStop[] {
return [ return [
{ id: "st1", name: "Stop A", systemId: "sys1", coordinates: { latitude: 10, longitude: 20 }, updatedTimeMs: Date.now() }, { 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 }, updatedTimeMs: 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 }, updatedTimeMs: Date.now() }, { id: "st3", name: "Stop C", systemId: "sys3", coordinates: { latitude: 30, longitude: 40 }, updatedTime: Date.now() },
]; ];
} }
export function generateMockOrderedStops(): IOrderedStop[] { export function generateMockOrderedStops(): IOrderedStop[] {
return [ return [
{ stopId: "st1", routeId: "r1", position: 1, systemId: "sys1", updatedTimeMs: Date.now(), }, { stopId: "st1", routeId: "r1", position: 1, systemId: "sys1", updatedTime: Date.now(), },
{ stopId: "st1", routeId: "r2", position: 2, systemId: "sys1", updatedTimeMs: Date.now(), }, { stopId: "st1", routeId: "r2", position: 2, systemId: "sys1", updatedTime: Date.now(), },
{ stopId: "st2", routeId: "r1", position: 3, systemId: "sys1", updatedTimeMs: Date.now(), }, { stopId: "st2", routeId: "r1", position: 3, systemId: "sys1", updatedTime: Date.now(), },
{ stopId: "st2", routeId: "r2", position: 4, systemId: "sys1", updatedTimeMs: Date.now(), }, { stopId: "st2", routeId: "r2", position: 4, systemId: "sys1", updatedTime: Date.now(), },
]; ];
} }
export function generateMockEtas(): IEta[] { export function generateMockEtas(): IEta[] {
return [ return [
{ shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1", updatedTimeMs: Date.now() }, { shuttleId: "sh1", stopId: "st1", secondsRemaining: 120, systemId: "sys1", updatedTime: Date.now() },
{ shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1", updatedTimeMs: Date.now() }, { shuttleId: "sh1", stopId: "st2", secondsRemaining: 180, systemId: "sys1", updatedTime: Date.now() },
{ shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1", updatedTimeMs: Date.now() }, { shuttleId: "sh2", stopId: "st3", secondsRemaining: 240, systemId: "sys1", updatedTime: Date.now() },
]; ];
} }