Drive search form dropdowns from VALID_MIN/MAX_CONNECTIONS; warn on short transfers
Index page connection time dropdowns now iterate over valid_min_connections
and valid_max_connections passed from the view, so any change to the sets
in app.py is reflected automatically (also adds the missing 45 min option).
Add ⚠️ next to transfer times under 80 minutes in the results table;
store connection_minutes in each trip dict to support the comparison.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
19656f412a
commit
e7695a5e49
4 changed files with 11 additions and 4 deletions
8
app.py
8
app.py
|
|
@ -36,7 +36,13 @@ DESTINATIONS = {
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
today = date.today().isoformat()
|
today = date.today().isoformat()
|
||||||
return render_template('index.html', destinations=DESTINATIONS, today=today)
|
return render_template(
|
||||||
|
'index.html',
|
||||||
|
destinations=DESTINATIONS,
|
||||||
|
today=today,
|
||||||
|
valid_min_connections=sorted(VALID_MIN_CONNECTIONS),
|
||||||
|
valid_max_connections=sorted(VALID_MAX_CONNECTIONS),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
VALID_MIN_CONNECTIONS = {45, 50, 60, 70, 80, 90, 100, 110, 120}
|
VALID_MIN_CONNECTIONS = {45, 50, 60, 70, 80, 90, 100, 110, 120}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
Minimum connection time (Paddington → St Pancras)
|
Minimum connection time (Paddington → St Pancras)
|
||||||
</label>
|
</label>
|
||||||
<select id="min_connection" name="min_connection" class="form-control">
|
<select id="min_connection" name="min_connection" class="form-control">
|
||||||
{% for mins in [50, 60, 70, 80, 90, 100, 110, 120] %}
|
{% for mins in valid_min_connections %}
|
||||||
<option value="{{ mins }}" {% if mins == 50 %}selected{% endif %}>{{ mins }} min</option>
|
<option value="{{ mins }}" {% if mins == 50 %}selected{% endif %}>{{ mins }} min</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
Maximum connection time (Paddington → St Pancras)
|
Maximum connection time (Paddington → St Pancras)
|
||||||
</label>
|
</label>
|
||||||
<select id="max_connection" name="max_connection" class="form-control">
|
<select id="max_connection" name="max_connection" class="form-control">
|
||||||
{% for mins in [60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180] %}
|
{% for mins in valid_max_connections %}
|
||||||
<option value="{{ mins }}" {% if mins == 110 %}selected{% endif %}>{{ mins }} min</option>
|
<option value="{{ mins }}" {% if mins == 110 %}selected{% endif %}>{{ mins }} min</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
<br><span style="font-size:0.75rem;color:#718096">{{ row.ticket_name }}</span>
|
<br><span style="font-size:0.75rem;color:#718096">{{ row.ticket_name }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="col-transfer" style="padding:0.6rem 0.8rem;color:#4a5568">
|
<td class="col-transfer" style="padding:0.6rem 0.8rem;color:#4a5568">
|
||||||
{{ row.connection_duration }}
|
{{ row.connection_duration }}{% if row.connection_minutes < 80 %} ⚠️{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td style="padding:0.6rem 0.8rem;font-weight:600">
|
<td style="padding:0.6rem 0.8rem;font-weight:600">
|
||||||
{{ row.depart_st_pancras }}
|
{{ row.depart_st_pancras }}
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ def combine_trips(
|
||||||
'arrive_paddington': gwr['arrive_paddington'],
|
'arrive_paddington': gwr['arrive_paddington'],
|
||||||
'headcode': gwr.get('headcode', ''),
|
'headcode': gwr.get('headcode', ''),
|
||||||
'gwr_duration': _fmt_duration(int((arr_pad - dep_bri).total_seconds() / 60)),
|
'gwr_duration': _fmt_duration(int((arr_pad - dep_bri).total_seconds() / 60)),
|
||||||
|
'connection_minutes': int((dep_stp - arr_pad).total_seconds() / 60),
|
||||||
'connection_duration': _fmt_duration(int((dep_stp - arr_pad).total_seconds() / 60)),
|
'connection_duration': _fmt_duration(int((dep_stp - arr_pad).total_seconds() / 60)),
|
||||||
'depart_st_pancras': es['depart_st_pancras'],
|
'depart_st_pancras': es['depart_st_pancras'],
|
||||||
'arrive_destination': es['arrive_destination'],
|
'arrive_destination': es['arrive_destination'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue