totals row
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user