mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
update remove implementation and tests
This commit is contained in:
@@ -20,10 +20,6 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return this.system;
|
||||
}
|
||||
|
||||
public async getSystemById(systemId: string) {
|
||||
return this.findEntityById(systemId, this.systems);
|
||||
}
|
||||
|
||||
public async getStopsBySystemId(systemId: string) {
|
||||
return this.stops.filter(stop => stop.systemId === systemId);
|
||||
}
|
||||
@@ -100,12 +96,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
}
|
||||
|
||||
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
|
||||
} else {
|
||||
this.systems.push(system); // Add new
|
||||
}
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
public async addOrUpdateRoute(route: IRoute): Promise<void> {
|
||||
@@ -175,8 +166,14 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return await this.removeEntityByMatcherIfExists((value) => value.id === entityId, arrayToSearchIn);
|
||||
}
|
||||
|
||||
public async removeSystemIfExists(systemId: string): Promise<ISystem | null> {
|
||||
return await this.removeEntityByIdIfExists(systemId, this.systems);
|
||||
public async removeSystemIfExists(): Promise<ISystem | null> {
|
||||
if (this.system !== null) {
|
||||
const system = this.system;
|
||||
this.system = null;
|
||||
return system;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async removeRouteIfExists(routeId: string): Promise<IRoute | null> {
|
||||
@@ -206,7 +203,7 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
}
|
||||
|
||||
public async clearSystemData() {
|
||||
this.systems = [];
|
||||
this.system = null;
|
||||
}
|
||||
|
||||
public async clearShuttleData(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user