patch internal tooling for prod

This commit is contained in:
SowinskiBraeden committed 2026-06-29 11:38:08 -07:00
1 parent e9dd0f07bf
commit 552b6f2d26
3 files changed
+28 -6

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ DEFAULT_DATABASE_URL = f"sqlite:///{BASE_DIR / 'data' / 'boker-dev.sqlite3'}"
DEFAULT_SECRET_KEY = "change-this-before-deploying"
ELIGIBLE_MIN_SESSIONS = 3
APP_VERSION = "2.5.29"
APP_VERSION = "2.5.30"
def load_local_env(env_path: Path) -> None:
+11 -5
View File
@@ -6,7 +6,7 @@ import string
from datetime import datetime, timedelta, timezone
from flask import Blueprint, current_app, flash, redirect, render_template, request, url_for
from sqlalchemy import or_
from sqlalchemy import extract, or_
from sqlalchemy.exc import IntegrityError
from boker.auth import (
@@ -205,19 +205,25 @@ def _top_leagues(limit: int = 8):
return [(league, count) for league, count in rows]
def _session_weekday_expression(dialect_name: str | None = None):
dialect_name = dialect_name or db.session.get_bind().dialect.name
if dialect_name == "sqlite":
return db.func.strftime("%w", PokerSession.session_date)
return extract("dow", PokerSession.session_date)
def _sessions_by_weekday() -> dict:
from sqlalchemy import func as f
rows = (
db.session.query(
f.strftime("%w", PokerSession.session_date).label("dow"),
f.count(PokerSession.id).label("cnt"),
_session_weekday_expression().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)],
+16
View File
@@ -3,6 +3,9 @@ import unittest
from datetime import datetime, timedelta, timezone
from pathlib import Path
from sqlalchemy import select
from sqlalchemy.dialects import postgresql
from app import create_app
from boker.auth import hash_password
from boker.db import db
@@ -107,6 +110,19 @@ class InternalAdminAccessTests(unittest.TestCase):
self.assertIn(b"Ledger events", response.data)
self.assertIn(b"Totals at a glance", response.data)
def test_session_weekday_expression_uses_postgresql_extract(self):
with self.app.app_context():
from boker.routes.internal import _session_weekday_expression
compiled = str(
select(_session_weekday_expression("postgresql")).compile(
dialect=postgresql.dialect()
)
)
self.assertIn("EXTRACT(dow FROM", compiled)
self.assertNotIn("strftime", compiled)
def test_admin_can_search_users(self):
self.login_as(self.admin_id)