From 37fbc3ef4596bc2edc345e1d000a5bfc9f7f96bb Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 20 Nov 2025 17:48:49 -0800 Subject: [PATCH] Make checkIfShuttleIsAtStop part of the ShuttleGetterRepository interface --- src/repositories/shuttle/RedisShuttleRepository.ts | 2 +- src/repositories/shuttle/ShuttleGetterRepository.ts | 8 ++++++++ .../shuttle/UnoptimizedInMemoryShuttleRepository.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/repositories/shuttle/RedisShuttleRepository.ts b/src/repositories/shuttle/RedisShuttleRepository.ts index 515f3cd..9098f56 100644 --- a/src/repositories/shuttle/RedisShuttleRepository.ts +++ b/src/repositories/shuttle/RedisShuttleRepository.ts @@ -447,7 +447,7 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt await this.redisClient.sRem(this.shuttleIsAtStopKey, shuttleId); } - private async checkIfShuttleIsAtStop(shuttleId: string) { + public async checkIfShuttleIsAtStop(shuttleId: string) { return await this.redisClient.sIsMember(this.shuttleIsAtStopKey, shuttleId); } diff --git a/src/repositories/shuttle/ShuttleGetterRepository.ts b/src/repositories/shuttle/ShuttleGetterRepository.ts index 1518c93..6011a43 100644 --- a/src/repositories/shuttle/ShuttleGetterRepository.ts +++ b/src/repositories/shuttle/ShuttleGetterRepository.ts @@ -95,6 +95,14 @@ export interface ShuttleGetterRepository extends EventEmitter { */ getShuttleLastStopArrival(shuttleId: string): Promise; + /** + * Determine if the shuttle is currently at a stop. + * If `true`, then calling `getShuttleLastStopArrival` will get + * the stop the shuttle is currently at. + * @param shuttleId + */ + checkIfShuttleIsAtStop(shuttleId: string): Promise; + /** * Check if a shuttle has arrived at a stop within the given delta. * Returns the stop if the shuttle is at a stop, otherwise undefined. diff --git a/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts b/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts index 8746bb0..ec30b84 100644 --- a/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts +++ b/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts @@ -223,7 +223,7 @@ export class UnoptimizedInMemoryShuttleRepository this.shuttlesAtStop.delete(shuttleId); } - private async checkIfShuttleIsAtStop(shuttleId: string) { + public async checkIfShuttleIsAtStop(shuttleId: string) { return this.shuttlesAtStop.has(shuttleId); }