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

View file

@ -351,9 +351,21 @@
});
}
function loadWalkonFares() {
for (var sectionId in WALKON_API_URLS) {
(function(id, url) {
fetch(url).then(function(r) { return r.json(); }).then(function(fares) {
mergeWalkonFares(id, fares);
updateDisplay();
});
})(sectionId, WALKON_API_URLS[sectionId]);
}
}
function initialiseResultsPage() {
if (currentNrClass === 'advance_std' || currentNrClass === 'advance_1st') loadMissingAdvanceFares();
updateDisplay();
loadWalkonFares();
startTimetableRefresh();
}
@ -500,7 +512,6 @@
{% set row_class = '' %}
{% endif %}
<tr class="{{ row_class }}" data-row-key="{{ row.row_key }}"
{% if row.ticket_price is not none %}data-walkon="{{ row.ticket_price }}"{% endif %}
{% if row.eurostar_price is not none %}data-es-std="{{ row.eurostar_price }}"{% endif %}>
{% if row.row_type == 'trip' %}
{% if section.direction == 'inbound' %}