Add 2-hour TTL cache check to SpaceDevs launch updater

Prevents hitting the SpaceDevs rate limit by skipping the API call
when the launches cache is still fresh (< 2 hours old), matching the
same TTL pattern already used for the active crewed flights cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-03-12 13:28:10 +00:00
parent d9b08f3e5b
commit 04cb3e8179
2 changed files with 15 additions and 0 deletions

View file

@ -321,6 +321,9 @@ def update_thespacedevs(config: flask.config.Config) -> None:
existing_data = agenda.thespacedevs.load_cached_launches(rocket_dir)
assert existing_data
if agenda.thespacedevs.is_launches_cache_fresh(rocket_dir):
return
# Update active crewed mission cache used by the launches page.
# Uses the 2-hour TTL; failures are handled internally with cache fallback.
active_crewed = agenda.thespacedevs.get_active_crewed_flights(rocket_dir)