Implement in-memory equivalents of both ETA repositories

This commit is contained in:
2025-11-11 20:21:40 -08:00
parent 7c5aeda4a9
commit 6a31609960
5 changed files with 165 additions and 15 deletions

View File

@@ -1,13 +1,22 @@
import { IEta } from "../../../entities/ShuttleRepositoryEntities";
import { ExternalSourceETARepository } from "./ExternalSourceETARepository";
import { BaseInMemoryETARepository } from "./BaseInMemoryETARepository";
import { ETARepositoryEvent } from "./ETAGetterRepository";
export class InMemoryExternalSourceETARepository extends BaseInMemoryETARepository 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 index = this.etas.findIndex((e) => e.stopId === stopId && e.shuttleId === shuttleId);
if (index === -1) {
return null;
}
const removedEta = this.etas[index];
this.etas.splice(index, 1);
this.emit(ETARepositoryEvent.ETA_REMOVED, removedEta);
return removedEta;
}
}