mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user