数据源统一为 bzzoiro,移除 Understat 与 injuries:
- 删除 src/data/understat.py / injuries.py 及相关测试
- 删除 injuries 模型与表;扩展 match_stats(xG 之外增加 big_chances/fouls)
- 新增 standings 表(联赛积分榜:位置/积分/xG/走势/分区)
- matches 表增加 source_event_id 血缘列,支撑统计回填
采集管线(bzzoiro 三条管线):
- events:赛程/比分(/events/),记录 source_event_id
- standings:积分榜快照(/leagues/{id}/standings/)
- stats:已完赛比赛详细统计回填(/events/{id}/stats/)
预测增强:
- standings_slice 替代 injuries_slice;积分榜专家替代阵容完整性专家
- AGENT_META runtime_config 同步更新
管理后台:
- ingest 路由重写为单一 bzzoiro 入口 + task 参数(events/standings/stats/all)
- 新增 /admin/data-completeness 数据完整性分析 API
- 数据源状态页简化为 bzzoiro 单源
前端:
- 采集页重构为任务驱动(比赛/积分榜/统计回填/全量)
- 新增「数据完整性」可视化页(覆盖率矩阵/字段完整率/健康摘要)
- 新增主站积分榜页(/standings)与比赛详情完整统计面板
- agent 名称同步更新(injuries→standings)
迁移 0015_bzzoiro_single_source 已在容器内验证通过,后端测试全部通过。
Co-Authored-By: new-provider/LongCat-2.0 <<EMAIL>>
33 lines
1004 B
Python
33 lines
1004 B
Python
"""共享 httpx 异步客户端(连接池复用 + 生命周期管理)。
|
|
|
|
使用方:
|
|
- src/llm/provider.py: LLM 调用
|
|
- src/data/bzzoiro.py: bzzoiro 比赛数据 / 积分榜 / 事件统计
|
|
|
|
生命周期由 FastAPI lifespan 管理(关闭时 aclose)。
|
|
调用方可通过 `timeout` 参数覆盖 per-request 超时。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import httpx
|
|
|
|
from src.core.config import settings
|
|
|
|
_shared_client: httpx.AsyncClient | None = None
|
|
|
|
|
|
def get_client() -> httpx.AsyncClient:
|
|
"""获取共享客户端(懒初始化)。"""
|
|
global _shared_client
|
|
if _shared_client is None or _shared_client.is_closed:
|
|
_shared_client = httpx.AsyncClient(timeout=settings.HTTP_DEFAULT_TIMEOUT)
|
|
return _shared_client
|
|
|
|
|
|
async def close_client() -> None:
|
|
"""关闭共享客户端(在 FastAPI shutdown 时调用)。"""
|
|
global _shared_client
|
|
if _shared_client is not None and not _shared_client.is_closed:
|
|
await _shared_client.aclose()
|
|
_shared_client = None
|