mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
remove all system related data from shuttle repository
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ShuttleGetterSetterRepository } from "./ShuttleGetterSetterRepository";
|
||||
import { IEntityWithId, IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||
import { IEntityWithId, IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../entities/entities";
|
||||
|
||||
/**
|
||||
* An unoptimized in memory repository.
|
||||
@@ -7,7 +7,6 @@ import { IEntityWithId, IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } f
|
||||
* switching to another data store later anyways)
|
||||
*/
|
||||
export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetterRepository {
|
||||
private system: ISystem | null = null;
|
||||
private stops: IStop[] = [];
|
||||
private routes: IRoute[] = [];
|
||||
private shuttles: IShuttle[] = [];
|
||||
@@ -16,10 +15,6 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
|
||||
private subscribers: ((eta: IEta) => void)[] = [];
|
||||
|
||||
public async getSystemIfExists() {
|
||||
return this.system;
|
||||
}
|
||||
|
||||
public async getStopsBySystemId(systemId: string) {
|
||||
return this.stops.filter(stop => stop.systemId === systemId);
|
||||
}
|
||||
@@ -95,10 +90,6 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async updateSystem(system: ISystem): Promise<void> {
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
public async addOrUpdateRoute(route: IRoute): Promise<void> {
|
||||
const index = this.routes.findIndex((r) => r.id === route.id);
|
||||
if (index !== -1) {
|
||||
@@ -166,16 +157,6 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
return await this.removeEntityByMatcherIfExists((value) => value.id === entityId, arrayToSearchIn);
|
||||
}
|
||||
|
||||
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> {
|
||||
return await this.removeEntityByIdIfExists(routeId, this.routes);
|
||||
}
|
||||
@@ -202,10 +183,6 @@ export class UnoptimizedInMemoryShuttleRepository implements ShuttleGetterSetter
|
||||
}, this.etas);
|
||||
}
|
||||
|
||||
public async clearSystemData() {
|
||||
this.system = null;
|
||||
}
|
||||
|
||||
public async clearShuttleData(): Promise<void> {
|
||||
this.shuttles = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user