stats; Add total ban count to the stats page
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -35,6 +35,11 @@ def static_url(resource: str):
|
||||
return f"{config.STATIC_ROOT}/{resource}"
|
||||
|
||||
|
||||
def stats_table_total():
|
||||
return sum(row['bans'] for row in stats_table_data())
|
||||
|
||||
|
||||
@functools.cache
|
||||
def stats_table_data():
|
||||
with get_db() as db:
|
||||
curs = db.execute("SELECT board, count(*) as bans FROM bans GROUP BY board")
|
||||
@@ -50,6 +55,7 @@ _env.globals.update(
|
||||
"route_url": route_url,
|
||||
"static_url": static_url,
|
||||
"stats_table_data": stats_table_data,
|
||||
"stats_table_total": stats_table_total,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td>{{stats_table_total()}}</td>
|
||||
</tr>
|
||||
{% for row in stats_table_data() %}
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user