mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Rename properties in WillArriveAtStopPayload for more clarity
This commit is contained in:
@@ -406,8 +406,8 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
|
||||
shuttleId: shuttle.id,
|
||||
};
|
||||
this.emit(ShuttleRepositoryEvent.SHUTTLE_WILL_ARRIVE_AT_STOP, {
|
||||
lastArrival: lastStop,
|
||||
currentArrival: shuttleArrival,
|
||||
lastStopArrival: lastStop,
|
||||
willArriveAt: shuttleArrival,
|
||||
});
|
||||
await this.updateShuttleLastStopArrival(shuttleArrival);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ export type EtaRemovedEventPayload = IEta;
|
||||
export type EtaDataClearedEventPayload = IEta[];
|
||||
|
||||
export interface WillArriveAtStopPayload {
|
||||
lastArrival?: ShuttleStopArrival;
|
||||
currentArrival: ShuttleStopArrival;
|
||||
lastStopArrival?: ShuttleStopArrival;
|
||||
willArriveAt: ShuttleStopArrival;
|
||||
};
|
||||
|
||||
export interface ShuttleRepositoryEventPayloads {
|
||||
|
||||
@@ -3,13 +3,13 @@ import { ShuttleGetterSetterRepository } from "./ShuttleGetterSetterRepository";
|
||||
import { IOrderedStop, IRoute, IShuttle, IStop, shuttleHasArrivedAtStop } from "../../entities/ShuttleRepositoryEntities";
|
||||
import { IEntityWithId } from "../../entities/SharedEntities";
|
||||
import {
|
||||
ShuttleRepositoryEvent,
|
||||
ShuttleRepositoryEventListener,
|
||||
ShuttleRepositoryEventName,
|
||||
ShuttleRepositoryEventPayloads,
|
||||
ShuttleStopArrival,
|
||||
ShuttleTravelTimeDataIdentifier,
|
||||
ShuttleTravelTimeDateFilterArguments,
|
||||
ShuttleRepositoryEvent,
|
||||
ShuttleRepositoryEventListener,
|
||||
ShuttleRepositoryEventName,
|
||||
ShuttleRepositoryEventPayloads,
|
||||
ShuttleStopArrival,
|
||||
ShuttleTravelTimeDataIdentifier,
|
||||
ShuttleTravelTimeDateFilterArguments,
|
||||
} from "./ShuttleGetterRepository";
|
||||
|
||||
/**
|
||||
@@ -187,8 +187,8 @@ export class UnoptimizedInMemoryShuttleRepository
|
||||
shuttleId: shuttle.id,
|
||||
};
|
||||
this.emit(ShuttleRepositoryEvent.SHUTTLE_WILL_ARRIVE_AT_STOP, {
|
||||
lastArrival: lastStop,
|
||||
currentArrival: shuttleArrival,
|
||||
lastStopArrival: lastStop,
|
||||
willArriveAt: shuttleArrival,
|
||||
});
|
||||
await this.updateShuttleLastStopArrival(shuttleArrival);
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
|
||||
expect(listener).toHaveBeenCalledTimes(1);
|
||||
const emittedPayload = listener.mock.calls[0][0] as any;
|
||||
expect(emittedPayload.currentArrival).toEqual({
|
||||
expect(emittedPayload.willArriveAt).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop1.id,
|
||||
timestamp: arrivalTime,
|
||||
@@ -824,14 +824,14 @@ describe.each(repositoryImplementations)('$name', (holder) => {
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
|
||||
const firstPayload = listener.mock.calls[0][0] as any;
|
||||
expect(firstPayload.currentArrival).toEqual({
|
||||
expect(firstPayload.willArriveAt).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop1.id,
|
||||
timestamp: firstArrivalTime,
|
||||
});
|
||||
|
||||
const secondPayload = listener.mock.calls[1][0] as any;
|
||||
expect(secondPayload.currentArrival).toEqual({
|
||||
expect(secondPayload.willArriveAt).toEqual({
|
||||
shuttleId: shuttle.id,
|
||||
stopId: stop2.id,
|
||||
timestamp: secondArrivalTime,
|
||||
|
||||
@@ -157,8 +157,8 @@ export class InMemorySelfUpdatingETARepository extends BaseInMemoryETARepository
|
||||
}
|
||||
|
||||
private async handleShuttleWillArriveAtStop({
|
||||
lastArrival,
|
||||
currentArrival,
|
||||
lastStopArrival: lastArrival,
|
||||
willArriveAt: currentArrival,
|
||||
}: WillArriveAtStopPayload): Promise<void> {
|
||||
if (lastArrival) {
|
||||
// disallow cases where this gets triggered multiple times
|
||||
|
||||
@@ -179,8 +179,8 @@ export class RedisSelfUpdatingETARepository extends BaseRedisETARepository imple
|
||||
|
||||
|
||||
private async handleShuttleWillArriveAtStop({
|
||||
lastArrival,
|
||||
currentArrival,
|
||||
lastStopArrival: lastArrival,
|
||||
willArriveAt: currentArrival,
|
||||
}: WillArriveAtStopPayload) {
|
||||
// only update time traveled if last arrival exists
|
||||
if (lastArrival) {
|
||||
|
||||
Reference in New Issue
Block a user