Show Eurostar seat availability and no-prices notice
fetch_prices now returns {'price': ..., 'seats': ...} per departure.
Seat count (labelled "N at this price") is shown below the fare — it
reflects price-band depth rather than total remaining seats. A yellow
notice is shown when the API returns journeys but all prices are null
(tickets not yet on sale).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cd37f0619b
commit
05eec29b7d
4 changed files with 38 additions and 17 deletions
21
app.py
21
app.py
|
|
@ -146,14 +146,18 @@ def results(slug, travel_date):
|
|||
|
||||
trips = combine_trips(gwr_trains, eurostar_trains, travel_date, min_connection, max_connection)
|
||||
|
||||
# Annotate each trip with Eurostar Standard price and total cost
|
||||
# Annotate each trip with Eurostar Standard price, seats, and total cost
|
||||
for trip in trips:
|
||||
es_price = eurostar_prices.get(trip['depart_st_pancras'])
|
||||
es = eurostar_prices.get(trip['depart_st_pancras'], {})
|
||||
es_price = es.get('price')
|
||||
trip['eurostar_price'] = es_price
|
||||
if es_price is not None:
|
||||
trip['total_price'] = trip['ticket_price'] + es_price
|
||||
else:
|
||||
trip['total_price'] = None
|
||||
trip['eurostar_seats'] = es.get('seats')
|
||||
trip['total_price'] = trip['ticket_price'] + es_price if es_price is not None else None
|
||||
|
||||
# If the API returned journeys but every price is None, tickets aren't on sale yet
|
||||
no_prices_note = None
|
||||
if eurostar_prices and all(v.get('price') is None for v in eurostar_prices.values()):
|
||||
no_prices_note = 'Eurostar prices not yet available — tickets may not be on sale yet.'
|
||||
|
||||
unreachable_morning_services = find_unreachable_morning_eurostars(
|
||||
gwr_trains,
|
||||
|
|
@ -163,7 +167,9 @@ def results(slug, travel_date):
|
|||
max_connection,
|
||||
)
|
||||
for svc in unreachable_morning_services:
|
||||
svc['eurostar_price'] = eurostar_prices.get(svc['depart_st_pancras'])
|
||||
es = eurostar_prices.get(svc['depart_st_pancras'], {})
|
||||
svc['eurostar_price'] = es.get('price')
|
||||
svc['eurostar_seats'] = es.get('seats')
|
||||
|
||||
result_rows = sorted(
|
||||
[{'row_type': 'trip', **trip} for trip in trips]
|
||||
|
|
@ -196,6 +202,7 @@ def results(slug, travel_date):
|
|||
eurostar_count=len(eurostar_trains),
|
||||
from_cache=from_cache,
|
||||
error=error,
|
||||
no_prices_note=no_prices_note,
|
||||
eurostar_url=eurostar_url,
|
||||
rtt_url=rtt_url,
|
||||
rtt_bristol_url=rtt_bristol_url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue