Make checkIfShuttleIsAtStop part of the ShuttleGetterRepository interface

This commit is contained in:
2025-11-20 17:48:49 -08:00
parent ddab9b96ff
commit 37fbc3ef45
3 changed files with 10 additions and 2 deletions

View File

@@ -447,7 +447,7 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
await this.redisClient.sRem(this.shuttleIsAtStopKey, shuttleId); 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); return await this.redisClient.sIsMember(this.shuttleIsAtStopKey, shuttleId);
} }

View File

@@ -95,6 +95,14 @@ export interface ShuttleGetterRepository extends EventEmitter {
*/ */
getShuttleLastStopArrival(shuttleId: string): Promise<ShuttleStopArrival | undefined>; getShuttleLastStopArrival(shuttleId: string): Promise<ShuttleStopArrival | undefined>;
/**
* 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<boolean>;
/** /**
* Check if a shuttle has arrived at a stop within the given delta. * 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. * Returns the stop if the shuttle is at a stop, otherwise undefined.

View File

@@ -223,7 +223,7 @@ export class UnoptimizedInMemoryShuttleRepository
this.shuttlesAtStop.delete(shuttleId); this.shuttlesAtStop.delete(shuttleId);
} }
private async checkIfShuttleIsAtStop(shuttleId: string) { public async checkIfShuttleIsAtStop(shuttleId: string) {
return this.shuttlesAtStop.has(shuttleId); return this.shuttlesAtStop.has(shuttleId);
} }