add implementation for getEtasForStopId and getEtasForShuttleId

This commit is contained in:
2025-01-08 16:44:06 -08:00
parent a66e0ce9ad
commit 17b6f93f0e

View File

@@ -84,13 +84,35 @@ export class ApiBasedRepository implements GetterRepository {
return null;
}
public async getEtasForShuttleId(shuttleId: string): Promise<[]> {
public async getEtasForShuttleId(shuttleId: string): Promise<IEta[]> {
const shuttle = await this.getShuttleById(shuttleId);
const systemId = shuttle?.systemId;
if (!systemId) {
return [];
}
await this.updateEtasForSystemIfTTL(systemId);
if (!this.cache?.etasForShuttleId || !this.cache.etasForShuttleId[shuttleId]) {
return [];
}
public async getEtasForStopId(stopId: string): Promise<[]> {
return this.cache.etasForShuttleId[shuttleId];
}
public async getEtasForStopId(stopId: string): Promise<IEta[]> {
const stop = await this.getStopById(stopId);
const systemId = stop?.systemId;
if (!systemId) {
return [];
}
await this.updateEtasForSystemIfTTL(systemId);
if (!this.cache?.etasForStopId || !this.cache.etasForStopId[stopId]) {
return [];
}
return this.cache.etasForStopId[stopId];
}
public async updateEtasForSystemIfTTL(systemId: string) {
try {
@@ -262,7 +284,8 @@ ${json}`);
}
}
public async getStopById(stopId: string): Promise<| null> {
public async getStopById(stopId: string): Promise<IStop | null> {
// TODO: implement
return null;
}