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:
@@ -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 "",
|
||||
|
||||
@@ -5846,7 +5846,7 @@
|
||||
root.appendChild(charts);
|
||||
}
|
||||
|
||||
// ── 담당자별 작업 합계 — 메인(이 범위 최상위 작업, 중복 없이) + 하위(서버 subtasks-summary), 완료 수 ──
|
||||
// ── 담당자별 작업 합계 — 메인(이 범위 최상위 작업, 중복 없이) + 세부(서버 subtasks-summary — 모든 단계), 완료 수 ──
|
||||
let workloadCache = { scope: "", at: 0, subtasks: null, pending: null };
|
||||
function loadWorkloadSubtasks(force) {
|
||||
const fresh = workloadCache.scope === viewScope && Date.now() - workloadCache.at < 15000;
|
||||
@@ -5885,7 +5885,7 @@
|
||||
d.innerHTML = '<div class="pj-wl-drawer-dim"></div><aside class="pj-wl-panel" role="dialog" aria-label="업무 목록">' +
|
||||
'<header><div><b></b><small></small></div><button type="button" class="pj-icon-btn" data-act="close" title="닫기">' +
|
||||
'<span class="material-symbols-outlined">close</span></button></header><div class="pj-wl-panel-body"></div></aside>';
|
||||
d.querySelector("header b").textContent = person + " · " + kind + " 작업";
|
||||
d.querySelector("header b").textContent = person + " · " + kind; // kind = "메인 작업"·"세부 작업"
|
||||
d.querySelector("header small").textContent = "완료 " + done.length + " / " + items.length + (items.length ? " (" + Math.round(done.length / items.length * 100) + "%)" : "");
|
||||
const body = d.querySelector(".pj-wl-panel-body");
|
||||
const sortKey = function (t) { return (t.due_date || "9999") + (t.title || ""); };
|
||||
@@ -5902,7 +5902,7 @@
|
||||
btn.innerHTML = '<span class="material-symbols-outlined">' + ((t.completed_at || t.done) ? "check_circle" : "radio_button_unchecked") + "</span>" +
|
||||
'<span class="pj-wl-item-main"><span class="pj-wl-item-title"></span><small></small></span><em></em>';
|
||||
btn.querySelector(".pj-wl-item-title").textContent = t.title || "(제목 없음)";
|
||||
const parent = isSub && seenTask(t.parent_task_id);
|
||||
const parent = isSub && (seenTask(t.parent_task_id) || (t.parent_title ? { title: t.parent_title } : null));
|
||||
btn.querySelector("small").textContent = parent ? "상위: " + (parent.title || "") : (t.stage_name || "");
|
||||
btn.querySelector("em").textContent = t.due_date ? fmtShortDate(t.due_date) : "";
|
||||
btn.addEventListener("click", function () { openTaskById(t.id); });
|
||||
@@ -5968,7 +5968,8 @@
|
||||
function draw(subs) {
|
||||
Object.keys(rows).forEach(function (k) { rows[k].subs = []; });
|
||||
(subs || []).forEach(function (st) {
|
||||
if (!seen[st.parent_task_id]) return; // 이 범위의 메인 작업에 딸린 세부 작업만
|
||||
// 이 범위의 메인 작업에 딸린 세부 작업만 — 세부 작업의 세부 작업까지(root_task_id = 맨 위 메인 작업, 2026-10-08)
|
||||
if (!seen[st.root_task_id || st.parent_task_id]) return;
|
||||
row(st.assignee_email, st.assignee_name).subs.push(st);
|
||||
});
|
||||
const doneOf = function (list) { return list.filter(function (t) { return t.completed_at || t.done; }).length; };
|
||||
|
||||
Reference in New Issue
Block a user