diff --git a/templates/results.html b/templates/results.html index 999fe2a..12a2f97 100644 --- a/templates/results.html +++ b/templates/results.html @@ -116,6 +116,11 @@ {% if trips %} {% set best_mins = trips | map(attribute='total_minutes') | min %} {% set worst_mins = trips | map(attribute='total_minutes') | max %} + {% set priced_trips = trips | selectattr('total_price') | list %} + {% if priced_trips | length > 1 %} + {% set min_price = priced_trips | map(attribute='total_price') | min %} + {% set max_price = priced_trips | map(attribute='total_price') | max %} + {% endif %} {% endif %} {% for row in result_rows %} {% if row.row_type == 'trip' and row.total_minutes <= best_mins + 5 and trips | length > 1 %} @@ -144,7 +149,7 @@
{{ row.ticket_name }} - {{ row.connection_duration }}{% if row.connection_minutes < 80 %} ⚠️{% endif %} + {{ row.connection_duration }}{% if row.connection_minutes < 80 %} ⚠️{% endif %} {{ row.depart_st_pancras }} @@ -163,14 +168,14 @@ {% if row.total_minutes <= best_mins + 5 and trips | length > 1 %} - {{ row.total_duration }} ⚡ + {{ row.total_duration }} ⚡ {% elif row.total_minutes >= worst_mins - 5 and trips | length > 1 %} - {{ row.total_duration }} 🐢 + {{ row.total_duration }} 🐢 {% else %} {{ row.total_duration }} {% endif %} {% if row.total_price is not none %} -
£{{ "%.2f"|format(row.total_price) }} +
£{{ "%.2f"|format(row.total_price) }}{% if min_price is defined and max_price is defined %}{% if row.total_price <= min_price + 10 %} 💰{% elif row.total_price >= max_price - 10 %} 💸{% endif %}{% endif %} {% endif %} {% else %} diff --git a/tests/test_app.py b/tests/test_app.py index 937432f..d4de5c2 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -155,8 +155,8 @@ def test_results_marks_trips_within_five_minutes_of_fastest_and_slowest(monkeypa html = resp.get_data(as_text=True) assert resp.status_code == 200 - assert html.count('title="Fastest option"') == 2 - assert html.count('title="Slowest option"') == 2 + assert html.count('title="Fastest journey"') == 2 + assert html.count('title="Slowest journey"') == 2 assert '4h 50m ⚡' in html assert '4h 55m ⚡' in html assert '5h 20m 🐢' in html