From 0221bda314ac936905e8a3a58814e24e0d28056c Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Sun, 22 Dec 2024 19:56:46 -0800 Subject: [PATCH] add additional method to get shuttles by route --- src/repository.ts | 1 + src/unoptimizedInMemoryRepository.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/repository.ts b/src/repository.ts index b8dfb77..f0aafd3 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -67,6 +67,7 @@ export interface Repository { getShuttlesBySystemId(systemId: string): Promise; getShuttleById(shuttleId: string): Promise; + getShuttlesByRouteId(routeId: string): Promise; getEtasForShuttleId(shuttleId: string): Promise; getEtasForStopId(stopId: string): Promise; diff --git a/src/unoptimizedInMemoryRepository.ts b/src/unoptimizedInMemoryRepository.ts index d550843..e7f919f 100644 --- a/src/unoptimizedInMemoryRepository.ts +++ b/src/unoptimizedInMemoryRepository.ts @@ -41,6 +41,10 @@ export class UnoptimizedInMemoryRepository implements Repository { return this.shuttles.filter(shuttle => shuttle.systemId === systemId); } + public async getShuttlesByRouteId(routeId: string) { + return this.shuttles.filter(shuttle => shuttle.routeId === routeId); + } + public async getShuttleById(shuttleId: string) { return this.findEntityById(shuttleId, this.shuttles); }