mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
Unify the new ETA functionality across all shuttle repositories
This commit is contained in:
@@ -8,24 +8,11 @@ import {
|
||||
ShuttleRepositoryEventListener,
|
||||
ShuttleRepositoryEventName,
|
||||
ShuttleRepositoryEventPayloads,
|
||||
ShuttleStopArrival,
|
||||
ShuttleTravelTimeDataIdentifier,
|
||||
ShuttleTravelTimeDateFilterArguments,
|
||||
} from "./ShuttleGetterRepository";
|
||||
|
||||
export interface ShuttleStopArrival {
|
||||
stopId: string;
|
||||
timestamp: Date;
|
||||
}
|
||||
|
||||
export interface ShuttleTravelTimeDataIdentifier {
|
||||
routeId: string;
|
||||
fromStopId: string;
|
||||
toStopId: string;
|
||||
}
|
||||
|
||||
export interface ShuttleTravelTimeDateFilterArguments {
|
||||
from: Date;
|
||||
to: Date;
|
||||
}
|
||||
|
||||
export class RedisShuttleRepository extends EventEmitter implements ShuttleGetterSetterRepository {
|
||||
protected redisClient;
|
||||
|
||||
@@ -644,12 +631,16 @@ export class RedisShuttleRepository extends EventEmitter implements ShuttleGette
|
||||
await this.redisClient.hSet(key, this.createRedisHashFromOrderedStop(orderedStop));
|
||||
}
|
||||
|
||||
public async addOrUpdateEta(eta: IEta): Promise<void> {
|
||||
private async addOrUpdateEta(eta: IEta): Promise<void> {
|
||||
const key = this.createEtaKey(eta.shuttleId, eta.stopId);
|
||||
await this.redisClient.hSet(key, this.createRedisHashFromEta(eta));
|
||||
this.emit(ShuttleRepositoryEvent.ETA_UPDATED, eta);
|
||||
}
|
||||
|
||||
public async addOrUpdateEtaFromExternalSource(eta: IEta): Promise<void> {
|
||||
await this.addOrUpdateEta(eta);
|
||||
}
|
||||
|
||||
// Remove methods
|
||||
public async removeRouteIfExists(routeId: string): Promise<IRoute | null> {
|
||||
const route = await this.getRouteById(routeId);
|
||||
|
||||
Reference in New Issue
Block a user