mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update getShuttleById to move TTL check to other method
This commit is contained in:
@@ -211,18 +211,7 @@ export class ApiBasedRepository implements GetterRepository {
|
|||||||
let shuttle = this.cache.shuttleByShuttleId[shuttleId];
|
let shuttle = this.cache.shuttleByShuttleId[shuttleId];
|
||||||
if (!shuttle) return null;
|
if (!shuttle) return null;
|
||||||
|
|
||||||
// If the shuttle exists and not TTL, then return it
|
// Call getShuttlesBySystemId to update the data if not TTL
|
||||||
|
|
||||||
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
|
|
||||||
await this.updateShuttlesForSystemIfTTL(shuttle.systemId);
|
await this.updateShuttlesForSystemIfTTL(shuttle.systemId);
|
||||||
|
|
||||||
shuttle = this.cache.shuttleByShuttleId[shuttleId];
|
shuttle = this.cache.shuttleByShuttleId[shuttleId];
|
||||||
@@ -371,7 +360,7 @@ ${json}`);
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user