update method signatures to not include system id

This commit is contained in:
2025-04-07 19:17:14 -07:00
parent 0076d987ca
commit b6f3e4ccde
7 changed files with 46 additions and 47 deletions

View File

@@ -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.getRoutes(this.systemIdForConstructedData);
return await this.repository.getRoutes();
});
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.getStops(this.systemIdForConstructedData);
return await this.repository.getStops();
});
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.getShuttles(this.systemIdForConstructedData);
return await this.repository.getShuttles();
});
const params = {
@@ -184,7 +184,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
}
public async fetchAndUpdateEtaDataForExistingStopsForSystem() {
const stops = await this.repository.getStops(this.systemIdForConstructedData);
const stops = await this.repository.getStops();
await Promise.all(stops.map(async (stop) => {
let stopId = stop.id;
await this.fetchAndUpdateEtaDataForStopId(stopId);

View File

@@ -4,18 +4,17 @@ import { IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../entities/entitie
* Shuttle getter repository to be linked to a system.
*/
export interface ShuttleGetterRepository {
// TODO: Remove system ID argument from all getters
getStops(systemId: string): Promise<IStop[]>;
getStops(): Promise<IStop[]>;
getStopById(stopId: string): Promise<IStop | null>;
getRoutes(systemId: string): Promise<IRoute[]>;
getRoutes(): Promise<IRoute[]>;
getRouteById(routeId: string): Promise<IRoute | null>;
getShuttles(systemId: string): Promise<IShuttle[]>;
getShuttles(): Promise<IShuttle[]>;
getShuttleById(shuttleId: string): Promise<IShuttle | null>;
getShuttlesByRouteId(routeId: string): Promise<IShuttle[]>;
getEtas(shuttleId: string): Promise<IEta[]>;
getEtasForShuttleId(shuttleId: string): Promise<IEta[]>;
getEtasForStopId(stopId: string): Promise<IEta[]>;
getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null>;

View File

@@ -15,7 +15,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
private subscribers: ((eta: IEta) => void)[] = [];
public async getStops(systemId: string) {
public async getStops(): Promise<IStop[]> {
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 getRoutes(systemId: string) {
public async getRoutes(): Promise<IRoute[]> {
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 getShuttles(systemId: string) {
public async getShuttles(): Promise<IShuttle[]> {
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 getEtas(shuttleId: string) {
public async getEtasForShuttleId(shuttleId: string): Promise<IEta[]> {
return this.etas.filter(eta => eta.shuttleId === shuttleId);
}

View File

@@ -24,7 +24,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
const system = contextValue.findSystemById(parent.systemId);
if (!system) return null;
const etasForShuttle = await system.shuttleRepository.getEtas(parent.id);
const etasForShuttle = await system.shuttleRepository.getEtasForShuttleId();
if (!etasForShuttle) return null;
const computedEtas = await Promise.all(etasForShuttle.map(async ({

View File

@@ -9,7 +9,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return [];
}
return await system.shuttleRepository.getRoutes(parent.id);
return await system.shuttleRepository.getRoutes();
},
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.getStops(parent.id);
return await system.shuttleRepository.getStops();
},
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.getShuttles(parent.id);
return await system.shuttleRepository.getShuttles();
}
},
}