Stream GWR walk-on fares client-side instead of blocking page render

Walk-on fares are now always fetched in the browser via WALKON_API_URLS
rather than synchronously on the server. This means the page renders
immediately with timetable and Eurostar prices, and NR fares fill in
shortly after without delaying the initial load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-05-21 18:40:11 +01:00
parent b184e27a63
commit 03d2a53961
3 changed files with 16 additions and 21 deletions

17
app.py
View file

@ -497,22 +497,7 @@ def _results(station_crs, slug, travel_date, journey_type, return_date):
)
fare_direction = "to_paddington" if direction == "outbound" else "from_paddington"
gwr_fares = get_cached(gwr_cache_key, ttl=30 * 24 * 3600)
if gwr_fares is not None:
from_cache_parts.append(gwr_cache_key)
elif nr_provisional or es_provisional:
gwr_fares = {}
else:
gwr_fares = cached_fetch(
gwr_cache_key,
30 * 24 * 3600,
(
(lambda: gwr_fares_scraper.fetch(station_crs, section_date))
if fare_direction == "to_paddington"
else (lambda: gwr_fares_scraper.fetch(station_crs, section_date, direction=fare_direction))
),
"GWR fares",
)
gwr_fares = {}
cached_advance = get_cached(advance_cache_key, ttl=24 * 3600)
if direction == "outbound":