write logic to get eta for shuttle and stop id

This commit is contained in:
2025-01-07 19:54:39 -08:00
parent 9db745bd12
commit 1958af2593

View File

@@ -40,6 +40,20 @@ export class ApiBasedRepository implements GetterRepository {
}
public async getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null> {
const shuttle = await this.getShuttleById(shuttleId);
const systemId = shuttle?.systemId;
if (!systemId) {
return null;
}
if (this.initialCache?.etasForStopId !== undefined) {
const etas = this.initialCache.etasForStopId[systemId];
const foundEta = etas.find((eta) => eta.stopId === stopId);
if (foundEta) {
return foundEta;
}
}
return null;
}
@@ -76,7 +90,7 @@ export class ApiBasedRepository implements GetterRepository {
return Promise.resolve([]);
}
public async getShuttleById(shuttleId: string): Promise<| null> {
public async getShuttleById(shuttleId: string): Promise<IShuttle | null> {
return Promise.resolve(null);
}