Add sorting to all data types
- Add name-based sorting for entities with names - Add order-based sorting for ordered stops - Add "seconds remaining" based sorting for ETAs - Add tests to check sorting
This commit is contained in:
@@ -8,14 +8,16 @@ export const StopResolvers: Resolvers<ServerContext> = {
|
||||
if (!system) {
|
||||
return [];
|
||||
}
|
||||
return await system.shuttleRepository.getOrderedStopsByStopId(parent.id);
|
||||
const orderedStops = await system.shuttleRepository.getOrderedStopsByStopId(parent.id);
|
||||
return orderedStops.slice().sort((a, b) => a.position - b.position);
|
||||
},
|
||||
etas: async (parent, args, contextValue, _info) => {
|
||||
const system = contextValue.findSystemById(parent.systemId);
|
||||
if (!system) {
|
||||
return [];
|
||||
}
|
||||
return await system.shuttleRepository.getEtasForStopId(parent.id);
|
||||
const etas = await system.shuttleRepository.getEtasForStopId(parent.id);
|
||||
return etas.slice().sort((a, b) => a.secondsRemaining - b.secondsRemaining);
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user