mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add method to seed the cache for the system id
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { GetterRepository } from "./GetterRepository";
|
import { GetterRepository } from "./GetterRepository";
|
||||||
import { IEta, IOrderedStop, IRoute, IShuttle, IStop } from "../entities/entities";
|
import { IEta, IOrderedStop, IRoute, IShuttle, IStop, ISystem } from "../entities/entities";
|
||||||
|
|
||||||
export interface ApiBasedRepositoryCache {
|
export interface ApiBasedRepositoryCache {
|
||||||
etasForShuttleId?: {
|
etasForShuttleId?: {
|
||||||
@@ -39,6 +39,20 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seed the initial data in the cache, so data can be updated
|
||||||
|
* given the correct ID.
|
||||||
|
* Alternatively, pass in an `initialCache` with existing data
|
||||||
|
* (useful for testing).
|
||||||
|
* @param systemId
|
||||||
|
*/
|
||||||
|
public async seedCacheForSystemId(systemId: string): Promise<void> {
|
||||||
|
await this.getShuttlesBySystemId(systemId);
|
||||||
|
await this.getShuttlesByRouteId(systemId);
|
||||||
|
await this.getStopsBySystemId(systemId);
|
||||||
|
await this.getSystemById(systemId);
|
||||||
|
}
|
||||||
|
|
||||||
public async getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null> {
|
public async getEtaForShuttleAndStopId(shuttleId: string, stopId: string): Promise<IEta | null> {
|
||||||
const shuttle = await this.getShuttleById(shuttleId);
|
const shuttle = await this.getShuttleById(shuttleId);
|
||||||
const systemId = shuttle?.systemId;
|
const systemId = shuttle?.systemId;
|
||||||
@@ -110,7 +124,7 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getSystemById(systemId: string): Promise<| null> {
|
public async getSystemById(systemId: string): Promise<ISystem| null> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user