docs: update project docs and evaluation history pagination

This commit is contained in:
刘金宝
2026-06-11 10:15:06 +08:00
parent 6b40ba1079
commit a54c2d1c85
17 changed files with 607 additions and 211 deletions
+9 -2
View File
@@ -1,4 +1,4 @@
from sqlalchemy import delete, select
from sqlalchemy import delete, func, select
from sqlalchemy.orm import Session
from app.models.training_record import TrainingRecord, TrainingScoreDetail
@@ -46,12 +46,19 @@ class EvaluationRepository:
)
return self.db.scalar(stmt)
def list_by_user(self, user_id: str) -> list[TrainingRecord]:
def count_by_user(self, user_id: str) -> int:
"""历史评价计数:按外部 user_id 统计完整训练后的评价记录总数。"""
stmt = select(func.count()).select_from(TrainingRecord).where(TrainingRecord.external_user_id == user_id)
return int(self.db.scalar(stmt) or 0)
def list_by_user(self, user_id: str, limit: int, offset: int) -> list[TrainingRecord]:
"""历史评价:按外部 user_id 查询完整训练后的评价记录。"""
stmt = (
select(TrainingRecord)
.where(TrainingRecord.external_user_id == user_id)
.order_by(TrainingRecord.created_at.desc())
.limit(limit)
.offset(offset)
)
return list(self.db.scalars(stmt).all())