Various improvements

This commit is contained in:
Edward Betts 2026-03-31 10:42:30 +01:00
parent 2090268754
commit 876eb6a759
5 changed files with 98 additions and 72 deletions

View file

@ -3,8 +3,8 @@ Combine GWR Bristol→Paddington trains with Eurostar St Pancras→destination t
"""
from datetime import datetime, timedelta
MIN_CONNECTION_MINUTES = 75
MAX_CONNECTION_MINUTES = 140
MIN_CONNECTION_MINUTES = 50
MAX_CONNECTION_MINUTES = 110
MAX_GWR_MINUTES = 110
DATE_FMT = '%Y-%m-%d'
TIME_FMT = '%H:%M'
@ -72,14 +72,18 @@ def combine_trips(
if (dep_stp - arr_pad).total_seconds() / 60 > MAX_CONNECTION_MINUTES:
continue
total_mins = int((arr_dest - dep_bri).total_seconds() / 60)
trips.append({
'depart_bristol': gwr['depart_bristol'],
'arrive_paddington': gwr['arrive_paddington'],
'headcode': gwr.get('headcode', ''),
'gwr_duration': _fmt_duration(int((arr_pad - dep_bri).total_seconds() / 60)),
'connection_duration': _fmt_duration(int((dep_stp - arr_pad).total_seconds() / 60)),
'depart_st_pancras': es['depart_st_pancras'],
'arrive_destination': es['arrive_destination'],
'total_duration': _fmt_duration(int((arr_dest - dep_bri).total_seconds() / 60)),
'train_number': es.get('train_number', ''),
'total_duration': _fmt_duration(total_mins),
'total_minutes': total_mins,
'destination': es['destination'],
})
break # Only the earliest valid Eurostar per GWR departure