add whale/public picks to prediction history and new API endpoint

- Add _compute_whale_public_picks() to reconstruct whale/public picks from historical bets
- Merge whale_pick, public_pick, whale_hit, public_hit into last_20_predictions
- Add get_prediction_history(limit) for lightweight prediction+accuracy data
- Add /api/prediction-history endpoint (default 100, max 500)
- Add Whale and Public columns with HIT/MISS to Last 20 table in frontend
This commit is contained in:
2026-02-26 09:42:16 +05:00
parent 54501260b4
commit d1dc8f62fa
3 changed files with 225 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ class WebServer:
self.app.router.add_get("/api/patterns", self._handle_patterns)
self.app.router.add_get("/predictions", self._handle_predictions_page)
self.app.router.add_get("/api/predictions", self._handle_predictions)
self.app.router.add_get("/api/prediction-history", self._handle_prediction_history)
self.app.router.add_get("/ws", self._handle_ws)
self.app.router.add_static("/static/", STATIC_DIR, name="static")
@@ -118,6 +119,15 @@ class WebServer:
log.error("Prediction analysis query failed: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def _handle_prediction_history(self, request: web.Request) -> web.Response:
limit = min(int(request.query.get("limit", 100)), 500)
try:
data = await _run_sync(db.get_prediction_history, limit)
return web.json_response(data)
except Exception as e:
log.error("Prediction history 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"):