fix: unixepoch() не поддерживается в SQLite <3.38

Заменено на time.time() - 14*86400 через параметр.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-27 03:52:35 +10:00
co-authored by Claude Opus 4.6
parent d05e680a98
commit 144a592e5e
+4 -1
View File
@@ -566,13 +566,16 @@ async def admin_stats(request: Request):
from db import _conn
with _conn() as conn:
# Messages per day (last 14 days)
import time as _time
cutoff = _time.time() - 14 * 86400
daily = conn.execute(
"SELECT date(timestamp, 'unixepoch', '+10 hours') as day, "
"COUNT(*) as total, "
"SUM(CASE WHEN role='user' THEN 1 ELSE 0 END) as questions, "
"SUM(CASE WHEN role='assistant' THEN 1 ELSE 0 END) as answers "
"FROM messages WHERE timestamp > unixepoch() - 14*86400 "
"FROM messages WHERE timestamp > ? "
"GROUP BY day ORDER BY day DESC",
(cutoff,),
).fetchall()
# Totals
totals = conn.execute(