mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update resolvers to include timestamps
This commit is contained in:
@@ -24,6 +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,
|
||||||
|
updatedTimeMs: nextOrderedStopObject.updatedTimeMs
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
previousStop: async (parent, args, contextValue, _info): Promise<OrderedStop | null> => {
|
previousStop: async (parent, args, contextValue, _info): Promise<OrderedStop | null> => {
|
||||||
@@ -47,6 +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,
|
||||||
|
updatedTimeMs: previousOrderedStopObject.updatedTimeMs,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stop: async (parent, args, contextValue, _info) => {
|
stop: async (parent, args, contextValue, _info) => {
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ export const RouteResolvers: Resolvers<ServerContext> = {
|
|||||||
coordinates,
|
coordinates,
|
||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
orientationInDegrees
|
orientationInDegrees,
|
||||||
|
updatedTimeMs
|
||||||
}) => ({
|
}) => ({
|
||||||
coordinates: coordinates as Coordinates,
|
coordinates: coordinates as Coordinates,
|
||||||
name,
|
name,
|
||||||
@@ -22,6 +23,7 @@ export const RouteResolvers: Resolvers<ServerContext> = {
|
|||||||
id,
|
id,
|
||||||
orientationInDegrees,
|
orientationInDegrees,
|
||||||
systemId: parent.systemId,
|
systemId: parent.systemId,
|
||||||
|
updatedTimeMs,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
orderedStop: async (parent, args, contextValue, info) => {
|
orderedStop: async (parent, args, contextValue, info) => {
|
||||||
@@ -41,6 +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,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,6 +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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
etas: async (parent, args, contextValue, info) => {
|
etas: async (parent, args, contextValue, info) => {
|
||||||
@@ -27,17 +28,20 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
|||||||
const etasForShuttle = await system.shuttleRepository.getEtasForShuttleId(parent.id);
|
const etasForShuttle = await system.shuttleRepository.getEtasForShuttleId(parent.id);
|
||||||
if (!etasForShuttle) return null;
|
if (!etasForShuttle) return null;
|
||||||
|
|
||||||
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
const computedEtas = await Promise.all(
|
||||||
secondsRemaining,
|
etasForShuttle.map(async ({
|
||||||
stopId,
|
|
||||||
}): Promise<Eta | null> => {
|
|
||||||
return {
|
|
||||||
secondsRemaining,
|
secondsRemaining,
|
||||||
stopId,
|
stopId,
|
||||||
shuttle: parent,
|
updatedTimeMs
|
||||||
shuttleId: parent.id,
|
}): Promise<Eta | null> => {
|
||||||
systemId: system.id,
|
return {
|
||||||
}
|
secondsRemaining,
|
||||||
|
stopId,
|
||||||
|
shuttle: parent,
|
||||||
|
shuttleId: parent.id,
|
||||||
|
systemId: system.id,
|
||||||
|
updatedTimeMs,
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (computedEtas.every((eta) => eta !== null)) {
|
if (computedEtas.every((eta) => eta !== null)) {
|
||||||
@@ -59,6 +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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,6 +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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
route: async (parent, args, contextValue, _info) => {
|
route: async (parent, args, contextValue, _info) => {
|
||||||
@@ -55,6 +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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
shuttle: async (parent, args, contextValue, _info) => {
|
shuttle: async (parent, args, contextValue, _info) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user