Implement in-memory equivalents of both ETA repositories
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user