add pattern analysis feature with web dashboard and CLI

New /patterns page with 9 analyses: chair win bias, bet rank
correlations, hand type distributions, pot size buckets, streaks,
hourly patterns, and recent-vs-overall comparison. Also adds a
standalone analyze.py CLI script for terminal output.
This commit is contained in:
2026-02-25 22:45:43 +05:00
parent e65b6b2cfb
commit 2b8e3dd456
6 changed files with 824 additions and 1 deletions

View File

@@ -41,6 +41,8 @@ class WebServer:
self.app.router.add_get("/api/hot-cold", self._handle_hot_cold)
self.app.router.add_get("/analytics", self._handle_analytics_page)
self.app.router.add_get("/api/analytics", self._handle_analytics)
self.app.router.add_get("/patterns", self._handle_patterns_page)
self.app.router.add_get("/api/patterns", self._handle_patterns)
self.app.router.add_get("/ws", self._handle_ws)
self.app.router.add_static("/static/", STATIC_DIR, name="static")
@@ -90,6 +92,18 @@ class WebServer:
path = os.path.join(STATIC_DIR, "analytics.html")
return web.FileResponse(path)
async def _handle_patterns_page(self, request: web.Request) -> web.Response:
path = os.path.join(STATIC_DIR, "patterns.html")
return web.FileResponse(path)
async def _handle_patterns(self, request: web.Request) -> web.Response:
try:
data = await _run_sync(db.get_pattern_analysis)
return web.json_response(data)
except Exception as e:
log.error("Pattern analysis query failed: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def _handle_analytics(self, request: web.Request) -> web.Response:
period = request.query.get("period", "all")
if period not in ("1h", "6h", "24h", "7d", "all"):