diff --git a/boker/routes/internal.py b/boker/routes/internal.py index 339f4d5..a8d5083 100644 --- a/boker/routes/internal.py +++ b/boker/routes/internal.py @@ -206,18 +206,19 @@ def _top_leagues(limit: int = 8): def _sessions_by_weekday() -> dict: - from sqlalchemy import func as f + from sqlalchemy import extract + rows = ( db.session.query( - f.strftime("%w", PokerSession.session_date).label("dow"), - f.count(PokerSession.id).label("cnt"), + extract("dow", PokerSession.session_date).label("dow"), + db.func.count(PokerSession.id).label("cnt"), ) .group_by("dow") .all() ) counts = {str(i): 0 for i in range(7)} for row in rows: - counts[str(row.dow)] = row.cnt + counts[str(int(row.dow))] = row.cnt return { "labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "data": [counts[str(i)] for i in range(7)], diff --git a/tests/test_internal.py b/tests/test_internal.py index 2a5ef14..f489477 100644 --- a/tests/test_internal.py +++ b/tests/test_internal.py @@ -105,6 +105,7 @@ class InternalAdminAccessTests(unittest.TestCase): self.assertIn(b"Active users", response.data) self.assertIn(b"Activity breakdown", response.data) self.assertIn(b"Ledger events", response.data) + self.assertIn(b"Sessions by day of week", response.data) self.assertIn(b"Totals at a glance", response.data) def test_admin_can_search_users(self):