diff --git a/src/repositories/shuttle/RedisShuttleRepository.ts b/src/repositories/shuttle/RedisShuttleRepository.ts index 6c0ccdc..1b4d952 100644 --- a/src/repositories/shuttle/RedisShuttleRepository.ts +++ b/src/repositories/shuttle/RedisShuttleRepository.ts @@ -369,7 +369,16 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt travelTimeTimestamp = Date.now(), ) { const isAtStop = await this.checkIfShuttleIsAtStop(shuttle.id); - const arrivedStop = await this.getArrivedStopIfExists(shuttle); + + let arrivedStop: IStop | undefined; + + if (isAtStop) { + // Allow retrieval of the same stop + // Will still return undefined when the shuttle leaves the stop + arrivedStop = await this.getArrivedStopIfExists(shuttle, false); + } else { + arrivedStop = await this.getArrivedStopIfExists(shuttle, true); + } // Will not fire *any* events if the same stop const lastStop = await this.getShuttleLastStopArrival(shuttle.id); diff --git a/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts b/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts index f6fbafa..5239099 100644 --- a/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts +++ b/src/repositories/shuttle/UnoptimizedInMemoryShuttleRepository.ts @@ -184,7 +184,17 @@ export class UnoptimizedInMemoryShuttleRepository travelTimeTimestamp = Date.now(), ) { const isAtStop = await this.checkIfShuttleIsAtStop(shuttle.id); - const arrivedStop = await this.getArrivedStopIfExists(shuttle); + + let arrivedStop: IStop | undefined; + + if (isAtStop) { + // Allow retrieval of the same stop + // Will still return undefined when the shuttle leaves the stop + arrivedStop = await this.getArrivedStopIfExists(shuttle, false); + } else { + arrivedStop = await this.getArrivedStopIfExists(shuttle, true); + } + // Will not fire *any* events if the same stop const lastStop = await this.getShuttleLastStopArrival(shuttle.id);