mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
Call getArrivedStopIfExists based on different parameter
This commit is contained in:
@@ -369,7 +369,16 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
|
|||||||
travelTimeTimestamp = Date.now(),
|
travelTimeTimestamp = Date.now(),
|
||||||
) {
|
) {
|
||||||
const isAtStop = await this.checkIfShuttleIsAtStop(shuttle.id);
|
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
|
// Will not fire *any* events if the same stop
|
||||||
const lastStop = await this.getShuttleLastStopArrival(shuttle.id);
|
const lastStop = await this.getShuttleLastStopArrival(shuttle.id);
|
||||||
|
|||||||
@@ -184,7 +184,17 @@ export class UnoptimizedInMemoryShuttleRepository
|
|||||||
travelTimeTimestamp = Date.now(),
|
travelTimeTimestamp = Date.now(),
|
||||||
) {
|
) {
|
||||||
const isAtStop = await this.checkIfShuttleIsAtStop(shuttle.id);
|
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
|
// Will not fire *any* events if the same stop
|
||||||
const lastStop = await this.getShuttleLastStopArrival(shuttle.id);
|
const lastStop = await this.getShuttleLastStopArrival(shuttle.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user