we have a working dashboard
This commit is contained in:
+16
-2
@@ -13,7 +13,21 @@ bp = Blueprint('dashboard', __name__)
|
||||
@bp.route('/')
|
||||
def index():
|
||||
db = get_db()
|
||||
lastseven = db.execute(
|
||||
'SELECT * FROM totals WHERE datetime(date) > datetime("now", "-8 days")'
|
||||
fourweeks = db.execute(
|
||||
'SELECT * FROM totals ORDER BY date DESC LIMIT 56'
|
||||
).fetchall()
|
||||
lastseven = {}
|
||||
for row in fourweeks:
|
||||
if row['date'] not in lastseven:
|
||||
lastseven[row['date']] = {}
|
||||
if row['entity'] == 'contract':
|
||||
stops = row['delstops'] + row['pustops']
|
||||
pkgs = row['delpkgs'] + row['pupkgs']
|
||||
lastseven[row['date']]['stops'] = stops
|
||||
lastseven[row['date']]['pkgs'] = pkgs
|
||||
lastseven[row['date']]['pkgsperstop'] = round(pkgs / stops, 2)
|
||||
if row['entity'] == 'terminal' :
|
||||
lastseven[row['date']]['termpkgs'] = row['prepkgs']
|
||||
lastseven[row['date']]['percenttermvol'] = round(100 * stops / row['prepkgs'], 2)
|
||||
|
||||
return render_template('dashboard/index.html', lastseven=lastseven)
|
||||
|
||||
@@ -7,18 +7,22 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Contract Stops</th>
|
||||
<th>Terminal Packages</th>
|
||||
<th>% of Terminal Volume</th>
|
||||
<th>Stops</th>
|
||||
<th>Packages</th>
|
||||
<th>Packages<br>per Stop</th>
|
||||
<th>Terminal<br>Package<br>Volume</th>
|
||||
<th>Percent of<br>Terminal Volume</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in lastseven %}
|
||||
{% for date in lastseven %}
|
||||
<tr>
|
||||
<td>{{ row['date'] }}</td>
|
||||
<td>{{ row['constp'] }}</td>
|
||||
<td>{{ row['termpkg'] }}</td>
|
||||
<td>{{ row['percent'] }}</td>
|
||||
<td>{{ date }}</td>
|
||||
<td>{{ lastseven[date]['stops'] }}</td>
|
||||
<td>{{ lastseven[date]['pkgs'] }}</td>
|
||||
<td>{{ lastseven[date]['pkgsperstop'] }}</td>
|
||||
<td>{{ lastseven[date]['termpkgs'] }}</td>
|
||||
<td>{{ lastseven[date]['percenttermvol'] }}%</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user