we have a working dashboard

This commit is contained in:
2021-10-16 22:27:03 -06:00
parent 60de5aeae5
commit e4c051b8c2
2 changed files with 28 additions and 10 deletions
+16 -2
View File
@@ -13,7 +13,21 @@ bp = Blueprint('dashboard', __name__)
@bp.route('/') @bp.route('/')
def index(): def index():
db = get_db() db = get_db()
lastseven = db.execute( fourweeks = db.execute(
'SELECT * FROM totals WHERE datetime(date) > datetime("now", "-8 days")' 'SELECT * FROM totals ORDER BY date DESC LIMIT 56'
).fetchall() ).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) return render_template('dashboard/index.html', lastseven=lastseven)
+12 -8
View File
@@ -7,18 +7,22 @@
<thead> <thead>
<tr> <tr>
<th>Date</th> <th>Date</th>
<th>Contract Stops</th> <th>Stops</th>
<th>Terminal Packages</th> <th>Packages</th>
<th>% of Terminal Volume</th> <th>Packages<br>per Stop</th>
<th>Terminal<br>Package<br>Volume</th>
<th>Percent of<br>Terminal Volume</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in lastseven %} {% for date in lastseven %}
<tr> <tr>
<td>{{ row['date'] }}</td> <td>{{ date }}</td>
<td>{{ row['constp'] }}</td> <td>{{ lastseven[date]['stops'] }}</td>
<td>{{ row['termpkg'] }}</td> <td>{{ lastseven[date]['pkgs'] }}</td>
<td>{{ row['percent'] }}</td> <td>{{ lastseven[date]['pkgsperstop'] }}</td>
<td>{{ lastseven[date]['termpkgs'] }}</td>
<td>{{ lastseven[date]['percenttermvol'] }}%</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>