fix: 代码审查问题修复

- unit_of_work.py: 简化为纯 session 上下文管理器,消除 double-close 风险
- validation.py: 移除未使用的 import,简化 _score_to_1x2 逻辑
- repositories.py: 将 func 导入移到模块顶层
- 更新所有 get_uow() 调用点使用新接口(yield session 而非 uow 对象)
This commit is contained in:
shangfangjian
2026-09-15 01:18:35 +08:00
parent 74586aa5b7
commit 53e602b4f6
8 changed files with 40 additions and 86 deletions
+1 -3
View File
@@ -5,7 +5,7 @@ Repository 只负责查询,不负责事务提交。
"""
from __future__ import annotations
from sqlalchemy import select
from sqlalchemy import func, select
from sqlalchemy.orm import selectinload
from sqlalchemy.ext.asyncio import AsyncSession
@@ -38,8 +38,6 @@ class MatchRepository:
self, league_id: int, home_team_id: int, away_team_id: int, date
) -> Match | None:
"""按联赛+主队+客队+日期查找比赛(天级匹配)。"""
from sqlalchemy import func
if hasattr(date, "date"):
date = date.date()