From a1c134973f39f405c40e18fb8cd91b7426cc6f34 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Mon, 18 Oct 2021 23:22:03 -0600 Subject: [PATCH] totals row --- flaskfdx/dashboard.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/flaskfdx/dashboard.py b/flaskfdx/dashboard.py index 5cdc9a2..026e35f 100644 --- a/flaskfdx/dashboard.py +++ b/flaskfdx/dashboard.py @@ -19,6 +19,9 @@ def index(): ).fetchall() lastseven = {} stops = 0 + totstops = 0 + totpkgs = 0 + tottermpkgs = 0 i = 0 while len(lastseven) < 7: if fourweeks[i]['date'] not in lastseven: @@ -26,13 +29,22 @@ def index(): if fourweeks[i]['entity'] == 'contract': stops = fourweeks[i]['delstops'] + fourweeks[i]['pustops'] pkgs = fourweeks[i]['delpkgs'] + fourweeks[i]['pupkgs'] + totstops += stops + totpkgs += pkgs lastseven[fourweeks[i]['date']]['stops'] = stops lastseven[fourweeks[i]['date']]['pkgs'] = pkgs lastseven[fourweeks[i]['date']]['pkgsperstop'] = round(pkgs / stops, 2) i += 1 if fourweeks[i]['entity'] == 'terminal' : + tottermpkgs += fourweeks[i]['prepkgs'] lastseven[fourweeks[i]['date']]['termpkgs'] = fourweeks[i]['prepkgs'] lastseven[fourweeks[i]['date']]['percenttermvol'] = round(100 * stops / fourweeks[i]['prepkgs'], 2) + lastseven['Totals'] = {} + lastseven['Totals']['pkgs'] = totpkgs + lastseven['Totals']['stops'] = totstops + lastseven['Totals']['pkgsperstop'] = round(totpkgs / totstops, 2) + lastseven['Totals']['termpkgs'] = tottermpkgs + lastseven['Totals']['percenttermvol'] = round( 100 * totstops / tottermpkgs, 2) return render_template('dashboard/index.html', lastseven=lastseven)