Add task_details to the single-asset endpoint response
GET /assets/{id} never returned task_details (the schema didn't even
declare the field), unlike GET /shots/{id} which already populated it
correctly. This silently broke the asset detail panel's task list -
surfaced while wiring real task data into it on the frontend.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -474,10 +474,19 @@ async def get_asset(
|
||||
# This avoids a separate COUNT query
|
||||
active_tasks = [task for task in asset.tasks if task.deleted_at is None]
|
||||
task_count = len(active_tasks)
|
||||
|
||||
|
||||
asset_data = AssetResponse.model_validate(asset)
|
||||
asset_data.task_count = task_count
|
||||
|
||||
asset_data.task_details = [
|
||||
TaskStatusInfo(
|
||||
task_type=task.task_type,
|
||||
status=task.status,
|
||||
task_id=task.id,
|
||||
assigned_user_id=task.assigned_user_id
|
||||
)
|
||||
for task in active_tasks
|
||||
]
|
||||
|
||||
return asset_data
|
||||
|
||||
|
||||
|
||||
+14
-13
@@ -25,19 +25,6 @@ class AssetUpdate(BaseModel):
|
||||
status: Optional[AssetStatus] = None
|
||||
|
||||
|
||||
class AssetResponse(AssetBase):
|
||||
id: int
|
||||
project_id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
# Summary information
|
||||
task_count: int = 0
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class TaskStatusInfo(BaseModel):
|
||||
task_type: str # Changed from TaskType enum to str to support custom task types
|
||||
status: str # Changed from TaskStatus enum to str to support custom statuses
|
||||
@@ -45,6 +32,20 @@ class TaskStatusInfo(BaseModel):
|
||||
assigned_user_id: Optional[int] = None
|
||||
|
||||
|
||||
class AssetResponse(AssetBase):
|
||||
id: int
|
||||
project_id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
# Summary information
|
||||
task_count: int = 0
|
||||
task_details: List[TaskStatusInfo] = Field(default_factory=list, description="Detailed task information")
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class AssetListResponse(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user