mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
rename update method and update return types
This commit is contained in:
@@ -59,7 +59,7 @@ export class ApiBasedShuttleRepositoryLoader implements ShuttleRepositoryLoader
|
||||
name: system.fullname,
|
||||
};
|
||||
|
||||
await this.repository.addOrUpdateSystem(constructedSystem);
|
||||
await this.repository.updateSystem(constructedSystem);
|
||||
systemIds.delete(constructedSystem.id);
|
||||
}));
|
||||
} else {
|
||||
|
||||
@@ -4456,7 +4456,7 @@ const etas: IEta[] = [
|
||||
|
||||
export async function loadShuttleTestData(repository: ShuttleGetterSetterRepository) {
|
||||
await Promise.all(systems.map(async (system) => {
|
||||
await repository.addOrUpdateSystem(system);
|
||||
await repository.updateSystem(system);
|
||||
}));
|
||||
await Promise.all(routes.map(async (route) => {
|
||||
await repository.addOrUpdateRoute(route);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||
|
||||
export interface ShuttleGetterRepository {
|
||||
getSystemIfExists(): Promise<ISystem[]>;
|
||||
getSystemById(systemId: string): Promise<ISystem | null>;
|
||||
getSystemIfExists(): Promise<ISystem | null>;
|
||||
|
||||
getStopsBySystemId(systemId: string): Promise<IStop[]>;
|
||||
getStopById(stopId: string): Promise<IStop | null>;
|
||||
|
||||
@@ -12,14 +12,13 @@ import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entitie
|
||||
*/
|
||||
export interface ShuttleGetterSetterRepository extends ShuttleGetterRepository {
|
||||
// Setter methods
|
||||
addOrUpdateSystem(system: ISystem): Promise<void>;
|
||||
updateSystem(system: ISystem): Promise<void>;
|
||||
addOrUpdateRoute(route: IRoute): Promise<void>;
|
||||
addOrUpdateShuttle(shuttle: IShuttle): Promise<void>;
|
||||
addOrUpdateStop(stop: IStop): Promise<void>;
|
||||
addOrUpdateOrderedStop(orderedStop: IOrderedStop): Promise<void>;
|
||||
addOrUpdateEta(eta: IEta): Promise<void>;
|
||||
|
||||
removeSystemIfExists(systemId: string): Promise<ISystem | null>;
|
||||
removeRouteIfExists(routeId: string): Promise<IRoute | null>;
|
||||
removeShuttleIfExists(shuttleId: string): Promise<IShuttle | null>;
|
||||
removeStopIfExists(stopId: string): Promise<IStop | null>;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { IEntityWithId, IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } f
|
||||
* switching to another data store later anyways)
|
||||
*/
|
||||
export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetterRepository {
|
||||
private systems: ISystem[] = [];
|
||||
private system: ISystem | null = null;
|
||||
private stops: IStop[] = [];
|
||||
private routes: IRoute[] = [];
|
||||
private shuttles: IShuttle[] = [];
|
||||
@@ -17,7 +17,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
private subscribers: ((eta: IEta) => void)[] = [];
|
||||
|
||||
public async getSystemIfExists() {
|
||||
return this.systems;
|
||||
return this.system;
|
||||
}
|
||||
|
||||
public async getSystemById(systemId: string) {
|
||||
@@ -99,7 +99,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async addOrUpdateSystem(system: ISystem): Promise<void> {
|
||||
public async updateSystem(system: ISystem): Promise<void> {
|
||||
const index = this.systems.findIndex((s) => s.id === system.id);
|
||||
if (index !== -1) {
|
||||
this.systems[index] = system; // Update existing
|
||||
|
||||
Reference in New Issue
Block a user