Implement remaining logic for RedisExternalSourceETARepository

This commit is contained in:
2025-11-11 20:24:55 -08:00
parent 6a31609960
commit e03e962ab9
2 changed files with 14 additions and 5 deletions

View File

@@ -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> => ({

View File

@@ -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;
}
}