auto-sync: 2026-05-21 00:28:29

This commit is contained in:
cfdaily
2026-05-21 00:28:29 +08:00
parent 95110e9b86
commit 6d69eca7c5
+24
View File
@@ -366,6 +366,30 @@ async def add_review(project_id: str, task_id: str, body: Dict[str, Any]):
return {"ok": True, "review_id": review.id}
@router.patch("/tasks/{task_id}")
async def patch_task(project_id: str, task_id: str, body: Dict[str, Any]):
"""更新任务元数据(归档、标题等)"""
bb = _bb(project_id)
task = bb.get_task(task_id)
if not task:
raise HTTPException(404, f"Task {task_id} not found")
allowed = {"archived", "title", "description", "priority", "risk_level"}
updates = {k: v for k, v in body.items() if k in allowed}
if not updates:
return {"ok": True}
# 直接用 SQL 更新
import sqlite3
conn = sqlite3.connect(str(bb.db_path), timeout=5)
try:
set_clause = ", ".join(f"{k}=?" for k in updates)
conn.execute(f"UPDATE tasks SET {set_clause}, updated_at=datetime('now') WHERE id=?",
(*updates.values(), task_id))
conn.commit()
finally:
conn.close()
return {"ok": True}
# --- Per-task Events & Experiences ---
@router.get("/tasks/{task_id}/events")