TaskPulse/backend/app/schemas/task.py
Steven b04c0ce321 feat: agent avatars, task tags, search, edit/delete agents, cron readability, timezone fix
- Agent avatars: first-letter + deterministic color avatar in all views
- Agent management: edit (name/description) and delete with confirmation
- Execution API: validates agent existence, returns 410 if deleted
- Task tags: JSON array field, editable with tag pills UI
- Task search: by name (?q=) and by tags (?tags=) and by status
- Task edit: simplified to name/tags/description only (not agent params)
- Cron display: human-readable Chinese (e.g. '每5分钟', '每天 09:00')
- Timezone fix: UTC→local via dayjs.utc().local() across all pages
- Content area: full width (removed max-width:1200px constraints)
- Login page: standalone layout without sidebar
2026-06-15 23:33:28 +08:00

43 lines
1.1 KiB
Python

"""Pydantic schemas — ScheduledTask."""
from datetime import datetime
from pydantic import BaseModel, Field
class TaskCreate(BaseModel):
name: str = Field(..., max_length=256)
description: str = Field(default="")
cron_expression: str = Field(..., max_length=64)
grace_period: int = Field(default=300, ge=0)
tags: list[str] = Field(default_factory=list)
class TaskUpdate(BaseModel):
name: str | None = Field(None, max_length=256)
description: str | None = None
cron_expression: str | None = None
grace_period: int | None = None
status: str | None = None # active / paused / stopped
tags: list[str] | None = None
class TaskOut(BaseModel):
id: int
agent_id: int
agent_name: str = ""
name: str
description: str
cron_expression: str
grace_period: int
status: str
tags: list[str] = Field(default_factory=list)
last_run_at: datetime | None = None
last_run_result: str | None = None
next_run_at: datetime | None = None
total_run_count: int = 0
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}