mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +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: add TTL values to everything
|
||||||
// TODO: remove RepositoryDataLoader and UnoptimizedInMemoryRepository
|
// 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 {
|
export interface ApiBasedRepositoryCache {
|
||||||
etasForShuttleId?: {
|
etasForShuttleId?: {
|
||||||
@@ -138,6 +139,14 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
|
||||||
if (json.ETAs && json.ETAs[stop.id]) {
|
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
|
// Continue with the parsing
|
||||||
json.ETAs[stop.id].forEach((jsonEta: any) => {
|
json.ETAs[stop.id].forEach((jsonEta: any) => {
|
||||||
// Update cache
|
// Update cache
|
||||||
@@ -151,10 +160,6 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
|
|
||||||
// TODO: create cache abstraction to deal with possibly undefined properties
|
// 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;
|
const shuttleId: string = jsonEta.busId;
|
||||||
if (!this.cache.etasForShuttleId[shuttleId]) {
|
if (!this.cache.etasForShuttleId[shuttleId]) {
|
||||||
this.cache.etasForShuttleId[shuttleId] = [];
|
this.cache.etasForShuttleId[shuttleId] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user