parent
12a2b739e8
commit
1e14a99419
3 changed files with 77 additions and 1 deletions
|
|
@ -48,11 +48,12 @@
|
|||
{% endblock %}
|
||||
|
||||
{% macro section(heading, item_list) %}
|
||||
{% if item_list %}
|
||||
{% set items = item_list | list %}
|
||||
<div class="heading"><h2>{{ heading }}</h2></div>
|
||||
<p><a href="{{ url_for("trip_stats") }}">Trip statistics</a></p>
|
||||
<p>{{ items | count }} trips</p>
|
||||
|
||||
{% if item_list %}
|
||||
<div>Total distance: {{ format_distance(total_distance) }}</div>
|
||||
|
||||
{% for transport_type, distance in distances_by_transport_type %}
|
||||
|
|
|
|||
34
templates/trip/stats.html
Normal file
34
templates/trip/stats.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% from "macros.html" import format_distance with context %}
|
||||
|
||||
{% set heading = "Trip statistics" %}
|
||||
|
||||
{% block title %}{{ heading }} - Edward Betts{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Trip statistics</h1>
|
||||
<div>Trips: {{ count }}</div>
|
||||
<div>Total distance: {{ format_distance(total_distance) }}</div>
|
||||
|
||||
{% for transport_type, distance in distances_by_transport_type %}
|
||||
<div>
|
||||
{{ transport_type | title }}
|
||||
distance: {{format_distance(distance) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% for year, year_stats in yearly_stats | dictsort %}
|
||||
<h4>{{ year }}</h4>
|
||||
<div>Trips in {{ year }}: {{ year_stats.count }}</div>
|
||||
<div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div>
|
||||
{% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
|
||||
<div>
|
||||
{{ transport_type | title }}
|
||||
distance: {{format_distance(distance) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue