fix: 全方位审查问题修复(P0~P3)
P0: ORM-迁移同步 - 新增 RawEvent/IngestFailure/DataQualityCheck/DataLineage 4 个模型类 - MatchStats 补充 xg_source/xg_updated_at/xg_source_record_id 字段 - 修复 server_default=_utcnow → func.now()(4 处) - BigInteger 导入 P1: - log_buffer.py 移除 threading.Lock(asyncio 单线程下无需锁) - 确认 context_builder/understat/injuries 等已有修复 P2: - Dockerfile 新增非 root 用户 + .dockerignore - 前端 fetchDashboard 修复 total 字段(改用 items.length) - 前端 fetchSystemConfig 改用真实 /admin/settings 端点 - 修复 validation.py return self"" → return self P3: - predict.py 缓存加 _CACHE_MAX_SIZE=200 淘汰 - eval.py get_eval_summary 加 limit 参数(默认 1000)+ 返回 total_settled - orchestrator.py agent provider 配置缓存 60s
This commit is contained in:
+14
-4
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from src.db.models import Prediction
|
||||
from src.db.unit_of_work import get_uow
|
||||
@@ -32,12 +32,22 @@ def _actual_1x2(home: int, away: int) -> str:
|
||||
return "2"
|
||||
|
||||
|
||||
async def get_eval_summary() -> dict:
|
||||
"""按 provider × 模型聚合评估。"""
|
||||
async def get_eval_summary(limit: int = 1000) -> dict:
|
||||
"""按 provider × 模型聚合评估。
|
||||
|
||||
P3-4: 默认限制评估最近 1000 条已结算预测,避免全表加载导致内存压力。
|
||||
可通过 eval 路由的 query 参数调整。
|
||||
"""
|
||||
async with get_uow() as session:
|
||||
# 先统计全量已结算数,用于前端展示"共 X 条,评估 Y 条"
|
||||
total_settled = (await session.execute(
|
||||
select(func.count()).where(Prediction.settled == True)
|
||||
)).scalar_one()
|
||||
stmt = (
|
||||
select(Prediction)
|
||||
.where(Prediction.settled == True)
|
||||
.order_by(Prediction.id.desc())
|
||||
.limit(limit)
|
||||
)
|
||||
result = await session.execute(stmt)
|
||||
rows = list(result.scalars().all())
|
||||
@@ -76,4 +86,4 @@ async def get_eval_summary() -> dict:
|
||||
"avg_score_rmse": round(avg_err, 2) if avg_err is not None else None,
|
||||
"avg_subjective_confidence": round(avg_conf, 2) if avg_conf is not None else None,
|
||||
})
|
||||
return {"summary": summary}
|
||||
return {"summary": summary, "total_settled": total_settled, "evaluated": len(rows)}
|
||||
|
||||
Reference in New Issue
Block a user