From 160e24460bc3b20d0e6391b99b577243a245bb1f Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Wed, 8 Jan 2025 17:36:54 -0800 Subject: [PATCH] update getShuttleById to move TTL check to other method --- src/repositories/ApiBasedRepository.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/repositories/ApiBasedRepository.ts b/src/repositories/ApiBasedRepository.ts index 93d0620..6195c88 100644 --- a/src/repositories/ApiBasedRepository.ts +++ b/src/repositories/ApiBasedRepository.ts @@ -211,18 +211,7 @@ export class ApiBasedRepository implements GetterRepository { let shuttle = this.cache.shuttleByShuttleId[shuttleId]; if (!shuttle) return null; - // If the shuttle exists and not TTL, then return it - - const now = Date.now(); - if ( - shuttle.millisecondsSinceEpoch !== undefined - && this.ttls.shuttleByShuttleId !== undefined - && now - shuttle.millisecondsSinceEpoch > this.ttls.shuttleByShuttleId - ) { - return shuttle; - } - - // Otherwise, call getShuttlesBySystemId to update the data + // Call getShuttlesBySystemId to update the data if not TTL await this.updateShuttlesForSystemIfTTL(shuttle.systemId); shuttle = this.cache.shuttleByShuttleId[shuttleId]; @@ -371,7 +360,7 @@ ${json}`); })); } } catch (e) { - + console.error(e); } }