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