mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Implement remaining logic for RedisExternalSourceETARepository
This commit is contained in:
@@ -6,7 +6,7 @@ export abstract class BaseRedisETARepository extends BaseRedisRepository impleme
|
||||
private static readonly ETA_KEY_PREFIX = 'shuttle:eta:';
|
||||
|
||||
// Helper methods
|
||||
private createEtaKey = (shuttleId: string, stopId: string) =>
|
||||
protected createEtaKey = (shuttleId: string, stopId: string) =>
|
||||
`${BaseRedisETARepository.ETA_KEY_PREFIX}${shuttleId}:${stopId}`;
|
||||
|
||||
createRedisHashFromEta = (eta: IEta): Record<string, string> => ({
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { IEta } from "../../../entities/ShuttleRepositoryEntities";
|
||||
import { BaseRedisETARepository } from "./BaseRedisETARepository";
|
||||
import { ExternalSourceETARepository } from "./ExternalSourceETARepository";
|
||||
import { ETARepositoryEvent } from "./ETAGetterRepository";
|
||||
|
||||
export class RedisExternalSourceETARepository extends BaseRedisETARepository implements ExternalSourceETARepository {
|
||||
addOrUpdateEtaFromExternalSource(eta: IEta): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
async addOrUpdateEtaFromExternalSource(eta: IEta): Promise<void> {
|
||||
await this.addOrUpdateEta(eta);
|
||||
}
|
||||
|
||||
removeEtaIfExists(shuttleId: string, stopId: string): Promise<IEta | null> {
|
||||
throw new Error("Method not implemented.");
|
||||
async removeEtaIfExists(shuttleId: string, stopId: string): Promise<IEta | null> {
|
||||
const existingEta = await this.getEtaForShuttleAndStopId(shuttleId, stopId);
|
||||
if (existingEta === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const key = this.createEtaKey(shuttleId, stopId);
|
||||
await this.redisClient.del(key);
|
||||
this.emit(ETARepositoryEvent.ETA_REMOVED, existingEta);
|
||||
return existingEta;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user