mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
rename get system method on shuttle repository, update tests
This commit is contained in:
@@ -39,7 +39,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
const query = new URLSearchParams(params).toString();
|
||||
|
||||
const systemIds = await this.constructExistingEntityIdSet(async () => {
|
||||
return await this.repository.getSystems();
|
||||
return await this.repository.getSystemIfExists();
|
||||
})
|
||||
|
||||
try {
|
||||
@@ -76,7 +76,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateRouteDataForExistingSystemsInRepository() {
|
||||
const systems = await this.repository.getSystems();
|
||||
const systems = await this.repository.getSystemIfExists();
|
||||
await Promise.all(systems.map(async (system) => {
|
||||
await this.fetchAndUpdateRouteDataForSystemId(system.id);
|
||||
}));
|
||||
@@ -132,7 +132,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateStopAndPolylineDataForRoutesInExistingSystemsInRepository() {
|
||||
const systems = await this.repository.getSystems();
|
||||
const systems = await this.repository.getSystemIfExists();
|
||||
await Promise.all(systems.map(async (system: ISystem) => {
|
||||
await this.fetchAndUpdateStopAndPolylineDataForRoutesWithSystemId(system.id);
|
||||
}));
|
||||
@@ -178,7 +178,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateShuttleDataForExistingSystemsInRepository() {
|
||||
const systems = await this.repository.getSystems();
|
||||
const systems = await this.repository.getSystemIfExists();
|
||||
await Promise.all(systems.map(async (system: ISystem) => {
|
||||
const systemId = system.id;
|
||||
await this.fetchAndUpdateShuttleDataForSystemId(systemId);
|
||||
@@ -244,7 +244,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
}
|
||||
|
||||
public async fetchAndUpdateEtaDataForExistingStopsForSystemsInRepository() {
|
||||
const systems = await this.repository.getSystems()
|
||||
const systems = await this.repository.getSystemIfExists()
|
||||
await Promise.all(systems.map(async (system: ISystem) => {
|
||||
const systemId = system.id;
|
||||
await this.fetchAndUpdateEtaDataForExistingStopsForSystemId(systemId);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||
|
||||
export interface ShuttleGetterRepository {
|
||||
getSystems(): Promise<ISystem[]>;
|
||||
getSystemIfExists(): Promise<ISystem[]>;
|
||||
getSystemById(systemId: string): Promise<ISystem | null>;
|
||||
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
|
||||
@@ -16,7 +16,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
|
||||
private subscribers: ((eta: IEta) => void)[] = [];
|
||||
|
||||
public async getSystems() {
|
||||
public async getSystemIfExists() {
|
||||
return this.systems;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Resolvers } from "../generated/graphql";
|
||||
export const QueryResolvers: Resolvers<ServerContext> = {
|
||||
Query: {
|
||||
systems: async (_parent, args, contextValue, _info) => {
|
||||
return await contextValue.shuttleRepository.getSystems();
|
||||
return await contextValue.shuttleRepository.getSystemIfExists();
|
||||
},
|
||||
system: async (_parent, args, contextValue, _info) => {
|
||||
if (!args.id) return null;
|
||||
|
||||
Reference in New Issue
Block a user