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:
2025-09-30 15:23:50 -07:00
parent c244a4b037
commit 415b461308
12 changed files with 262 additions and 19 deletions

View File

@@ -9,7 +9,8 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return [];
}
return await system.shuttleRepository.getRoutes();
const routes = await system.shuttleRepository.getRoutes();
return routes.slice().sort((a, b) => a.name.localeCompare(b.name));
},
stops: async (parent, _args, contextValue, _info) => {
const system = contextValue.findSystemById(parent.id);
@@ -17,7 +18,8 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return [];
}
return await system.shuttleRepository.getStops();
const stops = await system.shuttleRepository.getStops();
return stops.slice().sort((a, b) => a.name.localeCompare(b.name));
},
stop: async (parent, args, contextValue, _info) => {
if (!args.id) return null;
@@ -78,7 +80,8 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return [];
}
return await system.shuttleRepository.getShuttles();
const shuttles = await system.shuttleRepository.getShuttles();
return shuttles.slice().sort((a, b) => a.name.localeCompare(b.name));
},
parkingSystem: async (parent, _args, contextValue, _info) => {
const system = contextValue.findSystemById(parent.id);