docs: update project docs and evaluation history pagination
This commit is contained in:
@@ -19,6 +19,7 @@ from app.schemas.evaluation import (
|
||||
EvaluationListItem,
|
||||
EvaluationListResponse,
|
||||
EvaluationResponse,
|
||||
PaginationMeta,
|
||||
ScoreDetailItem,
|
||||
)
|
||||
from app.services.audit_service import AuditService
|
||||
@@ -235,9 +236,12 @@ class EvaluationService:
|
||||
"""用户 ID 兼容:Django 返回的 id 写入 external_user_id,纯数字时同步写入源库 user_id。"""
|
||||
return int(user_id) if str(user_id).isdigit() else None
|
||||
|
||||
def list_history(self, user_id: str) -> EvaluationListResponse:
|
||||
def list_history(self, user_id: str, page: int = 1, page_size: int = 10) -> EvaluationListResponse:
|
||||
"""历史评价:按 Django 用户中心 ID 查询完整训练后的 training_record。"""
|
||||
records = self.eval_repo.list_by_user(user_id)
|
||||
total = self.eval_repo.count_by_user(user_id)
|
||||
offset = (page - 1) * page_size
|
||||
records = self.eval_repo.list_by_user(user_id, limit=page_size, offset=offset)
|
||||
total_pages = (total + page_size - 1) // page_size if total else 0
|
||||
return EvaluationListResponse(
|
||||
items=[
|
||||
EvaluationListItem(
|
||||
@@ -249,7 +253,15 @@ class EvaluationService:
|
||||
pdf_exported=bool(record.pdf_file_path),
|
||||
)
|
||||
for record in records
|
||||
]
|
||||
],
|
||||
pagination=PaginationMeta(
|
||||
page=page,
|
||||
page_size=page_size,
|
||||
total=total,
|
||||
total_pages=total_pages,
|
||||
has_next=page < total_pages,
|
||||
has_prev=page > 1 and total_pages > 0,
|
||||
),
|
||||
)
|
||||
|
||||
def get_detail(self, evaluation_id: int, user_id: str) -> EvaluationDetailResponse:
|
||||
|
||||
Reference in New Issue
Block a user