Add price emoji indicators and hover text to results table
Show 💰 on total prices within £10 of the cheapest journey and 💸 within £10 of the most expensive, mirroring the ⚡/🐢 logic for journey time. Only applied when more than one priced trip exists. Add title attributes to ⚠️ ("Tight connection"), ⚡ ("Fastest journey"), and 🐢 ("Slowest journey") for accessibility and discoverability. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e7695a5e49
commit
d089d3d716
2 changed files with 11 additions and 6 deletions
|
|
@ -116,6 +116,11 @@
|
||||||
{% if trips %}
|
{% if trips %}
|
||||||
{% set best_mins = trips | map(attribute='total_minutes') | min %}
|
{% set best_mins = trips | map(attribute='total_minutes') | min %}
|
||||||
{% set worst_mins = trips | map(attribute='total_minutes') | max %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% for row in result_rows %}
|
{% for row in result_rows %}
|
||||||
{% if row.row_type == 'trip' and row.total_minutes <= best_mins + 5 and trips | length > 1 %}
|
{% if row.row_type == 'trip' and row.total_minutes <= best_mins + 5 and trips | length > 1 %}
|
||||||
|
|
@ -144,7 +149,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 }}{% if row.connection_minutes < 80 %} ⚠️{% endif %}
|
{{ row.connection_duration }}{% if row.connection_minutes < 80 %} <span title="Tight connection">⚠️</span>{% 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 }}
|
||||||
|
|
@ -163,14 +168,14 @@
|
||||||
</td>
|
</td>
|
||||||
<td style="padding:0.6rem 0.8rem;font-weight:600;white-space:nowrap">
|
<td style="padding:0.6rem 0.8rem;font-weight:600;white-space:nowrap">
|
||||||
{% if row.total_minutes <= best_mins + 5 and trips | length > 1 %}
|
{% if row.total_minutes <= best_mins + 5 and trips | length > 1 %}
|
||||||
<span style="color:#276749" title="Fastest option">{{ row.total_duration }} ⚡</span>
|
<span style="color:#276749" title="Fastest journey">{{ row.total_duration }} ⚡</span>
|
||||||
{% elif row.total_minutes >= worst_mins - 5 and trips | length > 1 %}
|
{% elif row.total_minutes >= worst_mins - 5 and trips | length > 1 %}
|
||||||
<span style="color:#c53030" title="Slowest option">{{ row.total_duration }} 🐢</span>
|
<span style="color:#c53030" title="Slowest journey">{{ row.total_duration }} 🐢</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span style="color:#00539f">{{ row.total_duration }}</span>
|
<span style="color:#00539f">{{ row.total_duration }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if row.total_price is not none %}
|
{% if row.total_price is not none %}
|
||||||
<br><span style="font-size:0.8rem;font-weight:700;color:#276749">£{{ "%.2f"|format(row.total_price) }}</span>
|
<br><span style="font-size:0.8rem;font-weight:700;color:#276749">£{{ "%.2f"|format(row.total_price) }}{% if min_price is defined and max_price is defined %}{% if row.total_price <= min_price + 10 %} <span title="Cheapest journey">💰</span>{% elif row.total_price >= max_price - 10 %} <span title="Most expensive journey">💸</span>{% endif %}{% endif %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,8 @@ def test_results_marks_trips_within_five_minutes_of_fastest_and_slowest(monkeypa
|
||||||
html = resp.get_data(as_text=True)
|
html = resp.get_data(as_text=True)
|
||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert html.count('title="Fastest option"') == 2
|
assert html.count('title="Fastest journey"') == 2
|
||||||
assert html.count('title="Slowest option"') == 2
|
assert html.count('title="Slowest journey"') == 2
|
||||||
assert '4h 50m ⚡' in html
|
assert '4h 50m ⚡' in html
|
||||||
assert '4h 55m ⚡' in html
|
assert '4h 55m ⚡' in html
|
||||||
assert '5h 20m 🐢' in html
|
assert '5h 20m 🐢' in html
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue