mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
rename methods in getter repository
This commit is contained in:
@@ -36,7 +36,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
public async fetchAndUpdateRouteDataForSystem() {
|
||||
const systemId = this.passioSystemId;
|
||||
const routeIdsToPrune = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getRoutesBySystemId(this.systemIdForConstructedData);
|
||||
return await this.repository.getRoutes(this.systemIdForConstructedData);
|
||||
});
|
||||
|
||||
const params = {
|
||||
@@ -89,7 +89,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
// Fetch from the API
|
||||
// Pass JSON output into two different methods to update repository
|
||||
const stopIdsToPrune = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getStopsBySystemId(this.systemIdForConstructedData);
|
||||
return await this.repository.getStops(this.systemIdForConstructedData);
|
||||
});
|
||||
|
||||
const params = {
|
||||
@@ -127,7 +127,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
public async fetchAndUpdateShuttleDataForSystem() {
|
||||
const systemId = this.passioSystemId;
|
||||
const shuttleIdsToPrune = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getShuttlesBySystemId(this.systemIdForConstructedData);
|
||||
return await this.repository.getShuttles(this.systemIdForConstructedData);
|
||||
});
|
||||
|
||||
const params = {
|
||||
@@ -184,7 +184,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateEtaDataForExistingStopsForSystem() {
|
||||
const stops = await this.repository.getStopsBySystemId(this.systemIdForConstructedData);
|
||||
const stops = await this.repository.getStops(this.systemIdForConstructedData);
|
||||
await Promise.all(stops.map(async (stop) => {
|
||||
let stopId = stop.id;
|
||||
await this.fetchAndUpdateEtaDataForStopId(stopId);
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../entities/entities";
|
||||
|
||||
/**
|
||||
* Shuttle getter repository to be linked to a system.
|
||||
*/
|
||||
export interface ShuttleGetterRepository {
|
||||
// TODO: Remove system ID argument from all getters
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
getStops(systemId: string): Promise<IStop[]>;
|
||||
getStopById(stopId: string): Promise<IStop | null>;
|
||||
|
||||
getRoutesBySystemId(systemId: string): Promise<IRoute[]>;
|
||||
getRoutes(systemId: string): Promise<IRoute[]>;
|
||||
getRouteById(routeId: string): Promise<IRoute | null>;
|
||||
|
||||
getShuttlesBySystemId(systemId: string): Promise<IShuttle[]>;
|
||||
getShuttles(systemId: string): Promise<IShuttle[]>;
|
||||
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
|
||||
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
|
||||
|
||||
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
|
||||
getEtas(shuttleId: string): Promise<IEta[]>;
|
||||
getEtasForStopId(stopId: string): Promise<IEta[]>;
|
||||
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
|
||||
private subscribers: ((eta: IEta) => void)[] = [];
|
||||
|
||||
public async getStopsBySystemId(systemId: string) {
|
||||
public async getStops(systemId: string) {
|
||||
return this.stops.filter(stop => stop.systemId === systemId);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return this.findEntityById(stopId, this.stops);
|
||||
}
|
||||
|
||||
public async getRoutesBySystemId(systemId: string) {
|
||||
public async getRoutes(systemId: string) {
|
||||
return this.routes.filter(route => route.systemId === systemId);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return this.findEntityById(routeId, this.routes);
|
||||
}
|
||||
|
||||
public async getShuttlesBySystemId(systemId: string) {
|
||||
public async getShuttles(systemId: string) {
|
||||
return this.shuttles.filter(shuttle => shuttle.systemId === systemId);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return this.findEntityById(shuttleId, this.shuttles);
|
||||
}
|
||||
|
||||
public async getEtasForShuttleId(shuttleId: string) {
|
||||
public async getEtas(shuttleId: string) {
|
||||
return this.etas.filter(eta => eta.shuttleId === shuttleId);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
||||
const system = contextValue.findSystemById(parent.systemId);
|
||||
if (!system) return null;
|
||||
|
||||
const etasForShuttle = await system.shuttleRepository.getEtasForShuttleId(parent.id);
|
||||
const etasForShuttle = await system.shuttleRepository.getEtas(parent.id);
|
||||
if (!etasForShuttle) return null;
|
||||
|
||||
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
||||
|
||||
@@ -9,7 +9,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
|
||||
return [];
|
||||
}
|
||||
|
||||
return await system.shuttleRepository.getRoutesBySystemId(parent.id);
|
||||
return await system.shuttleRepository.getRoutes(parent.id);
|
||||
},
|
||||
stops: async (parent, _args, contextValue, _info) => {
|
||||
const system = contextValue.findSystemById(parent.id);
|
||||
@@ -17,7 +17,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
|
||||
return [];
|
||||
}
|
||||
|
||||
return await system.shuttleRepository.getStopsBySystemId(parent.id);
|
||||
return await system.shuttleRepository.getStops(parent.id);
|
||||
},
|
||||
stop: async (parent, args, contextValue, _info) => {
|
||||
if (!args.id) return null;
|
||||
@@ -76,7 +76,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
|
||||
return [];
|
||||
}
|
||||
|
||||
return await system.shuttleRepository.getShuttlesBySystemId(parent.id);
|
||||
return await system.shuttleRepository.getShuttles(parent.id);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user