Add stopgap ETA of 1 second when the shuttle has arrived at a stop
This commit is contained in:
@@ -102,9 +102,25 @@ export class RedisSelfUpdatingETARepository extends BaseRedisETARepository imple
|
||||
}
|
||||
|
||||
private async handleShuttleUpdate(shuttle: IShuttle) {
|
||||
const isAtStop = await this.shuttleRepository.checkIfShuttleIsAtStop(shuttle.id);
|
||||
const lastStop = await this.shuttleRepository.getShuttleLastStopArrival(shuttle.id);
|
||||
if (!lastStop) return;
|
||||
|
||||
if (isAtStop) {
|
||||
// Update the ETA *to* the stop the shuttle is currently at,
|
||||
// before starting from the current stop as normal.
|
||||
// Account for cases where the shuttle arrived way earlier than
|
||||
// expected based on the calculated ETA.
|
||||
|
||||
await this.addOrUpdateEta({
|
||||
secondsRemaining: 1,
|
||||
shuttleId: shuttle.id,
|
||||
stopId: lastStop.stopId,
|
||||
systemId: shuttle.systemId,
|
||||
updatedTime: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
const lastOrderedStop = await this.shuttleRepository.getOrderedStopByRouteAndStopId(shuttle.routeId, lastStop.stopId);
|
||||
|
||||
await this.updateCascadingEta({
|
||||
|
||||
Reference in New Issue
Block a user