206555c2d8
- 数据库:generation_tasks 新增 error_info JSON / retry_count / auto_retry_enabled / auto_retry_max 字段 - 领域模型:mark_failed 支持结构化 error_info,mark_pending_from_failed 递增 retry_count - Repository:新增 list_by_user_filtered / count_by_user_filtered / list_by_project_filtered / count_by_project_filtered - Use Case:新增 RetryGenerationTaskUseCase(原地重试)、ListUserTasksFilteredUseCase - API:任务列表支持 status/task_type 筛选+分页,重试改为原地重试(复用task_id) - Worker:失败时结构化记录 error_info(含堆栈摘要),支持自动重试(指数退避,最大60s) - Schema:所有响应新增 error_info / retry_count / auto_retry 字段 - 单测:新增9个测试用例,51个状态测试全绿,80个相关测试无回归
54 lines
1.3 KiB
Python
Executable File
54 lines
1.3 KiB
Python
Executable File
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ProjectTaskResponse(BaseModel):
|
|
id: str
|
|
task_type: str
|
|
project_id: str
|
|
status: str
|
|
progress: float
|
|
current_step: str
|
|
error_message: str = ""
|
|
error_info: dict = Field(default_factory=dict)
|
|
user_message: str = ""
|
|
retryable: bool = False
|
|
retry_count: int = 0
|
|
source_id: str = ""
|
|
template_id: str = ""
|
|
created_at: datetime | None = None
|
|
updated_at: datetime | None = None
|
|
|
|
|
|
class ListProjectTasksResponse(BaseModel):
|
|
items: list[ProjectTaskResponse] = Field(default_factory=list)
|
|
total: int = 0
|
|
|
|
|
|
class UserTaskResponse(BaseModel):
|
|
"""用户级任务响应(跨 project,用于模板模式)。"""
|
|
|
|
id: str
|
|
task_type: str
|
|
project_id: str = ""
|
|
template_id: str = ""
|
|
status: str
|
|
progress: float
|
|
current_step: str
|
|
error_message: str = ""
|
|
error_info: dict = Field(default_factory=dict)
|
|
user_message: str = ""
|
|
retryable: bool = False
|
|
retry_count: int = 0
|
|
source_id: str = ""
|
|
created_at: datetime | None = None
|
|
updated_at: datetime | None = None
|
|
|
|
|
|
class ListTasksResponse(BaseModel):
|
|
"""用户级任务列表响应(GET /api/v1/tasks)。"""
|
|
|
|
items: list[UserTaskResponse] = Field(default_factory=list)
|
|
total: int = 0
|