stats; Add total ban count to the stats page

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2023-09-09 23:59:00 -07:00
parent 299de17dd3
commit 9a6c0d8b28
2 changed files with 10 additions and 0 deletions

View File

@@ -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,
}
)

View File

@@ -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>