docs: update project docs and evaluation history pagination
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user