54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from datetime import datetime
|
|
from typing import Literal
|
|
|
|
from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
|
|
|
|
|
class CreateTaskRequest(BaseModel):
|
|
platform: Literal["xiaohongshu", "douyin"]
|
|
hotspot_limit: int = Field(default=5, ge=1, le=10)
|
|
item_limit_per_hotspot: int = Field(
|
|
default=5,
|
|
ge=1,
|
|
le=10,
|
|
validation_alias=AliasChoices("item_limit_per_hotspot", "item_limit"),
|
|
)
|
|
comment_limit_per_item: int = Field(default=50, ge=10, le=100)
|
|
|
|
|
|
class TaskResponse(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
task_id: str = Field(validation_alias="id", serialization_alias="task_id")
|
|
platform: str
|
|
status: str
|
|
analysis_status: str
|
|
analysis_success_rate: float
|
|
hotspot_limit: int
|
|
item_limit_per_hotspot: int
|
|
comment_limit_per_item: int
|
|
total_items_count: int
|
|
processed_items_count: int
|
|
successful_items_count: int
|
|
failed_items_count: int
|
|
current_stage: str | None = None
|
|
current_stage_label: str | None = None
|
|
last_progress_at: datetime | None = None
|
|
running_seconds: int = 0
|
|
seconds_since_last_progress: int | None = None
|
|
running_duration_label: str = "刚刚"
|
|
last_progress_ago_label: str = "暂无记录"
|
|
is_progress_stale: bool = False
|
|
stale_threshold_minutes: int = 10
|
|
hotspots_count: int = 0
|
|
comments_count: int = 0
|
|
reports_count: int = 0
|
|
is_demo: bool = False
|
|
error_message: str | None
|
|
created_at: datetime
|
|
|
|
|
|
class CreateTaskResponse(BaseModel):
|
|
task_id: str
|
|
status: str
|