From 79e5fdf56bebf5cbcef899da013dffa8403d9c64 Mon Sep 17 00:00:00 2001 From: Patrick Kilian Date: Thu, 12 May 2022 17:27:51 -0600 Subject: [PATCH] Zeige Preisentwicklung von Consumables --- app/templates/statistics.html | 12 ++++++++++++ app/tools.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/app/templates/statistics.html b/app/templates/statistics.html index a012bc5..f02ba71 100644 --- a/app/templates/statistics.html +++ b/app/templates/statistics.html @@ -164,6 +164,7 @@
{{ tab_pane( @@ -188,6 +189,17 @@ false ) }} + {{ tab_pane( + vehicle.id|string + '_' + consumable.id|string + '_price', + chart( + consumable.price, + 'ref_' + vehicle.id|string + '_' + consumable.id|string + '_price', + '€ / '+consumable.unit, + url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id) + ), + false + ) + }}
{{ tab_script('vehicle_' + vehicle.id|string + '_' + consumable.id|string + '_tabs') }} diff --git a/app/tools.py b/app/tools.py index e7ff34a..08771b5 100644 --- a/app/tools.py +++ b/app/tools.py @@ -27,6 +27,7 @@ class ConsumableStats: self.average_amount_used = 0 self.average_amount = [] self.amounts = [] + self.price = [] pitstops = [ stop for stop in vehicle.pitstops if stop.consumable_id == consumable.id @@ -37,6 +38,7 @@ class ConsumableStats: for pitstop in pitstops: self.overall_amount += pitstop.amount self.amounts.append(StatsEvent(pitstop.date, pitstop.amount)) + self.price.append(StatsEvent(pitstop.date, pitstop.costs/pitstop.amount)) self.average_amount_fuelled = self.overall_amount / pitstop_count if pitstop_count > 1: overall_distance = (