Update getArrivedStopIfExists method to take an argument returnNextStopOnly

This commit is contained in:
2025-11-21 10:51:38 -08:00
parent c2f1a67a70
commit 712e311006
4 changed files with 56 additions and 26 deletions

View File

@@ -443,24 +443,14 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
}
}
/**
* Get the stop that the shuttle is currently at, if it exists.
*
* If the shuttle has a "last stop", it will only return the stop
* directly after the last stop. Otherwise, it may return any stop that
* is on the shuttle's route.
*
* @param shuttle
* @param degreeDelta
* @returns
*/
public async getArrivedStopIfExists(
shuttle: IShuttle,
returnNextStopOnly: boolean = false,
): Promise<IStop | undefined> {
const degreeDelta = this.shuttleStopArrivalDegreeDelta;
const lastStop = await this.getShuttleLastStopArrival(shuttle.id);
if (lastStop) {
if (lastStop && returnNextStopOnly) {
const lastOrderedStop = await this.getOrderedStopByRouteAndStopId(shuttle.routeId, lastStop.stopId);
const orderedStopAfter = lastOrderedStop?.nextStop;
if (orderedStopAfter) {