feat(tasks): define investigation report contract and history
This commit is contained in:
@@ -409,6 +409,24 @@ class OperationalTaskRepository:
|
||||
async def get_latest_report(self, task_id: str) -> dict | None:
|
||||
return await self._latest_artifact("operational_task_reports", task_id)
|
||||
|
||||
async def get_report(self, task_id: str, revision: int) -> dict | None:
|
||||
cursor = await self.connection.execute(
|
||||
"""SELECT document FROM workbench.operational_task_reports
|
||||
WHERE project_id=%s AND task_id=%s AND revision=%s""",
|
||||
(self.project_id, task_id, revision),
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
return row["document"] if row else None
|
||||
|
||||
async def list_reports(self, task_id: str, limit: int, offset: int) -> list[dict]:
|
||||
cursor = await self.connection.execute(
|
||||
"""SELECT document FROM workbench.operational_task_reports
|
||||
WHERE project_id=%s AND task_id=%s ORDER BY revision DESC
|
||||
LIMIT %s OFFSET %s""",
|
||||
(self.project_id, task_id, limit, offset),
|
||||
)
|
||||
return [row["document"] for row in await cursor.fetchall()]
|
||||
|
||||
async def _latest_artifact(self, table: str, task_id: str) -> dict | None:
|
||||
if table not in {"operational_task_plans", "operational_task_reports"}:
|
||||
raise ValueError("unsupported artifact table")
|
||||
@@ -535,7 +553,7 @@ class OperationalTaskRepository:
|
||||
SET document=document || jsonb_build_object(
|
||||
'lifecycle_status','resolved',
|
||||
'resolved_at',to_jsonb(%s::timestamptz),
|
||||
'resolution_reason',%s
|
||||
'resolution_reason',%s::text
|
||||
)
|
||||
WHERE project_id=%s AND task_id=%s
|
||||
AND COALESCE(document->>'lifecycle_status','active')='active'
|
||||
|
||||
Reference in New Issue
Block a user