From bc07fe5622999a66c5bde97fd35938eae42b904f Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Wed, 22 Jan 2025 20:05:47 -0800 Subject: [PATCH] add implementation for removeSystemIfExists --- .../UnoptimizedInMemoryRepository.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/repositories/UnoptimizedInMemoryRepository.ts b/src/repositories/UnoptimizedInMemoryRepository.ts index 18845ea..6aba616 100644 --- a/src/repositories/UnoptimizedInMemoryRepository.ts +++ b/src/repositories/UnoptimizedInMemoryRepository.ts @@ -148,28 +148,35 @@ export class UnoptimizedInMemoryRepository implements GetterSetterRepository { } } - removeSystemIfExists(systemId: string): Promise { - return Promise.resolve(null); + public async removeSystemIfExists(systemId: string): Promise { + const index = this.systems.findIndex((s) => s.id === systemId); + if (index > -1) { + const systemToReturn = this.systems[index]; + this.systems.splice(index, 1); + return systemToReturn; + } + + return null; } - removeRouteIfExists(routeId: string): Promise { - return Promise.resolve(null); + public async removeRouteIfExists(routeId: string): Promise { + return null; } - removeShuttleIfExists(shuttleId: string): Promise { - return Promise.resolve(null); + public async removeShuttleIfExists(shuttleId: string): Promise { + return null; } - removeStopIfExists(stopId: string): Promise { - return Promise.resolve(null); + public async removeStopIfExists(stopId: string): Promise { + return null; } - removeOrderedStopIfExists(stopId: string, routeId: string): Promise { - return Promise.resolve(null); + public async removeOrderedStopIfExists(stopId: string, routeId: string): Promise { + return null; } - removeEtaIfExists(shuttleId: string, stopId: string): Promise { - return Promise.resolve(null); + public async removeEtaIfExists(shuttleId: string, stopId: string): Promise { + return null; } public async clearSystemData() {