feat(project): workload chart counts nested subtasks

subtasks-summary now returns every level under the scope's main tasks
(recursive CTE, depth <= 20) with root_task_id and parent_title; the
dashboard groups by root_task_id. Also fix drawer header '세부 작업 작업'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 16:57:36 +09:00
parent 6a1c437635
commit ee9c04147a
4 changed files with 30 additions and 12 deletions
+16 -4
View File
@@ -487,16 +487,28 @@ class ProjectStore:
)
def list_subtasks_of(self, *, parent_ids: list[int]) -> list[dict[str, Any]]:
"""세부 업무 요약(대시보드 담당자별 집계·업무 목록 패널용) — id·부모·제목·마감일·완료·담당자."""
"""세부 업무 요약(대시보드 담당자별 집계·업무 목록 패널용) — id·부모·제목·마감일·완료·담당자.
세부 업무의 세부 업무까지 모든 단계(2026-10-08) — root_task_id = 맨 위 메인 업무(parent_ids 중 하나),
parent_title = 바로 위 업무 제목(목록 패널 "상위:" 표시). 깊이 20 단계에서 멈춘다(잘못된 순환 방어)."""
ids = sorted({int(i) for i in parent_ids})
if not ids:
return []
with self._pool.connection() as conn:
rows = conn.execute(
"SELECT id, parent_task_id, title, due_date, completed_at, assignee_email, assignee_name "
"FROM tasks WHERE parent_task_id = ANY(%s) ORDER BY id", (ids,),
"WITH RECURSIVE sub AS ("
" SELECT t.id, t.parent_task_id, t.parent_task_id AS root_task_id, 1 AS depth"
" FROM tasks t WHERE t.parent_task_id = ANY(%s)"
" UNION ALL"
" SELECT c.id, c.parent_task_id, s.root_task_id, s.depth + 1"
" FROM tasks c JOIN sub s ON c.parent_task_id = s.id WHERE s.depth < 20"
") "
"SELECT DISTINCT ON (t.id) t.id, t.parent_task_id, s.root_task_id, s.depth, t.title, t.due_date, t.completed_at,"
" t.assignee_email, t.assignee_name, p.title AS parent_title "
"FROM sub s JOIN tasks t ON t.id = s.id LEFT JOIN tasks p ON p.id = t.parent_task_id "
"ORDER BY t.id, s.depth", (ids,),
).fetchall()
return [{"id": int(r["id"]), "parent_task_id": int(r["parent_task_id"]), "title": r["title"] or "",
return [{"id": int(r["id"]), "parent_task_id": int(r["parent_task_id"]), "root_task_id": int(r["root_task_id"]),
"depth": int(r["depth"]), "parent_title": r["parent_title"] or "", "title": r["title"] or "",
"due_date": r["due_date"].isoformat() if r["due_date"] else None,
"completed_at": r["completed_at"].isoformat() if r["completed_at"] else None,
"assignee_email": r["assignee_email"] or "", "assignee_name": r["assignee_name"] or "",