mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
update caching behavior temporarily for updateEtasForSystemIfTTL
This commit is contained in:
@@ -5,7 +5,8 @@ const baseUrl = "https://passiogo.com/mapGetData.php"
|
||||
|
||||
// TODO: add TTL values to everything
|
||||
// TODO: remove RepositoryDataLoader and UnoptimizedInMemoryRepository
|
||||
// TODO: make milleseconds (TTL) required on everything
|
||||
// TODO: make milliseconds (TTL) required on everything
|
||||
// TODO: extract cache into its own class
|
||||
|
||||
export interface ApiBasedRepositoryCache {
|
||||
etasForShuttleId?: {
|
||||
@@ -138,6 +139,14 @@ export class ApiBasedRepository implements GetterRepository {
|
||||
const json = await response.json();
|
||||
|
||||
if (json.ETAs && json.ETAs[stop.id]) {
|
||||
if (!this.cache.etasForStopId) {
|
||||
this.cache.etasForStopId = {};
|
||||
}
|
||||
this.cache.etasForStopId[stop.id] = [];
|
||||
|
||||
// TODO: restore normal cache behavior
|
||||
this.cache.etasForShuttleId = {};
|
||||
|
||||
// Continue with the parsing
|
||||
json.ETAs[stop.id].forEach((jsonEta: any) => {
|
||||
// Update cache
|
||||
@@ -151,10 +160,6 @@ export class ApiBasedRepository implements GetterRepository {
|
||||
|
||||
// TODO: create cache abstraction to deal with possibly undefined properties
|
||||
|
||||
if (!this.cache.etasForStopId[stop.id]) {
|
||||
this.cache.etasForStopId[stop.id] = []
|
||||
}
|
||||
|
||||
const shuttleId: string = jsonEta.busId;
|
||||
if (!this.cache.etasForShuttleId[shuttleId]) {
|
||||
this.cache.etasForShuttleId[shuttleId] = [];
|
||||
|
||||
Reference in New Issue
Block a user