mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add implementation for getEtasForStopId and getEtasForShuttleId
This commit is contained in:
@@ -84,13 +84,35 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
return null;
|
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 [];
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
await this.updateEtasForSystemIfTTL(systemId);
|
||||||
|
|
||||||
|
if (!this.cache?.etasForStopId || !this.cache.etasForStopId[stopId]) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.cache.etasForStopId[stopId];
|
||||||
|
}
|
||||||
|
|
||||||
public async updateEtasForSystemIfTTL(systemId: string) {
|
public async updateEtasForSystemIfTTL(systemId: string) {
|
||||||
try {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user