Various improvements

This commit is contained in:
Edward Betts 2026-03-31 12:59:44 +01:00
parent 876eb6a759
commit 1fa2e68b31
5 changed files with 101 additions and 8 deletions

View file

@ -27,6 +27,8 @@ def combine_trips(
gwr_trains: list[dict],
eurostar_trains: list[dict],
travel_date: str,
min_connection_minutes: int = MIN_CONNECTION_MINUTES,
max_connection_minutes: int = MAX_CONNECTION_MINUTES,
) -> list[dict]:
"""
Return a list of valid combined trips, sorted by Bristol departure time.
@ -53,7 +55,7 @@ def combine_trips(
if int((arr_pad - dep_bri).total_seconds() / 60) > MAX_GWR_MINUTES:
continue
earliest_eurostar = arr_pad + timedelta(minutes=MIN_CONNECTION_MINUTES)
earliest_eurostar = arr_pad + timedelta(minutes=min_connection_minutes)
# Find only the earliest viable Eurostar for this GWR departure
for es in eurostar_trains:
@ -69,7 +71,7 @@ def combine_trips(
if dep_stp < earliest_eurostar:
continue
if (dep_stp - arr_pad).total_seconds() / 60 > MAX_CONNECTION_MINUTES:
if (dep_stp - arr_pad).total_seconds() / 60 > max_connection_minutes:
continue
total_mins = int((arr_dest - dep_bri).total_seconds() / 60)