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 "",
+5 -4
View File
@@ -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; };
+2
View File
@@ -1092,6 +1092,8 @@ Windows 트레이 프로그램 **DBX 알림**(`desktop/notifier/`, C# .NET Frame
빠진다(빈 목록이면 "없습니다"). 오른쪽 클릭 = 열지 않고 확인. [태그 모두 확인]·[알림 모두 읽음] = 그 목록을 비운다.
- **용어**: 프로젝트 모듈 화면 글자 "하위 작업" → **"세부 작업"**, "작업 추가" → **"메인 작업 추가"**(세부 작업 추가는 그대로).
대시보드 담당자별 막대 이름 "메인 작업"·"세부 작업".
- **담당자별 작업 합계 — 세부 작업의 세부 작업까지**: `list_subtasks_of` 가 재귀 CTE 로 모든 단계(깊이 20 까지)를 돌려주고
`root_task_id`(맨 위 메인 작업)·`parent_title`(바로 위 작업) 을 붙인다. 화면은 `root_task_id` 가 이 범위 메인 작업이면 센다.
- **회의록 보드 링크 복사**: [회의록 보드] 오른쪽 🔗(`#pj-meet-board-copy`) — 같은 `POST …/board`(없으면 만든다)로 주소를 받아
클립보드에(실패하면 주소 창). 한 번 받은 주소는 그 화면에서 다시 쓴다.
+7 -4
View File
@@ -696,6 +696,9 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
{ id: 501, parent_task_id: 101, title: "하위 1", assignee_email: "me@test.local", assignee_name: "Me", done: true, completed_at: "2026-09-29T10:00:00+09:00" },
{ id: 502, parent_task_id: 101, title: "하위 2", assignee_email: "bob@test.local", assignee_name: "Bob", done: false },
{ id: 503, parent_task_id: 103, title: "다른 프로젝트 하위", assignee_email: "bob@test.local", assignee_name: "Bob", done: true },
// 세부 작업의 세부 작업(2026-10-08) — root_task_id 로 맨 위 메인 작업을 따져 센다
{ id: 504, parent_task_id: 501, root_task_id: 101, depth: 2, parent_title: "하위 1", title: "하위 1-1", assignee_email: "me@test.local", assignee_name: "Me", done: false },
{ id: 505, parent_task_id: 503, root_task_id: 103, depth: 2, parent_title: "다른 프로젝트 하위", title: "다른 1-1", assignee_email: "bob@test.local", assignee_name: "Bob", done: true },
] } };
});
env.route("GET", /\/project\/api\/tasks\/502$/, function () { return { body: { task: detail(502, "하위 2", { parent_task_id: 101 }) } }; });
@@ -710,13 +713,13 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
return [g.querySelector(".pj-wl-name b").textContent].concat(Array.from(g.querySelectorAll(".pj-wl-val")).map(function (v) { return v.firstChild.textContent; })).join("|");
});
check("[대시보드 담당자별] 하위 작업 요청(이 프로젝트 범위)", !!asked);
check("[대시보드 담당자별] 세로 막대: 사람별 메인·하위 완료/전체(다른 프로젝트 하위 제외)",
JSON.stringify(groups) === JSON.stringify(["Me|1/2|1/1", "Bob|0/1|0/1"]), groups);
check("[대시보드 담당자별] 세로 막대: 사람별 메인·세부 완료/전체(세부의 세부 포함, 다른 프로젝트 제외)",
JSON.stringify(groups) === JSON.stringify(["Me|1/2|1/2", "Bob|0/1|0/1"]), groups);
// 막대 = 그 작업 전체, 채움 = 완료율(작업 수가 아니라) — Me 메인 1/2 → 50%, 하위 1/1 → 100%, Bob 0/1 → 0%
const pcts = Array.from(env.d.querySelectorAll(".pj-wl-done")).map(function (f) { return f.dataset.pct; });
check("[대시보드 담당자별] 채움 높이 = 완료율", JSON.stringify(pcts) === JSON.stringify(["50", "100", "0", "0"]), pcts);
check("[대시보드 담당자별] 채움 높이 = 완료율", JSON.stringify(pcts) === JSON.stringify(["50", "50", "0", "0"]), pcts);
const sum = env.d.querySelector(".pj-wl-sum").textContent.replace(/\s+/g, " ");
check("[대시보드 담당자별] 전체 완료 2/5 (40%)", /2 \/ 5 \(40%\)/.test(sum), sum);
check("[대시보드 담당자별] 전체 완료 2/6 (33%)", /2 \/ 6 \(33%\)/.test(sum), sum);
// 막대 → 오른쪽 패널(body 에) → 항목 → 편집 창
env.d.querySelectorAll(".pj-wl-group")[1].querySelector(".pj-wl-col.is-sub").click(); await settle();
const drawer = env.d.body.querySelector(".pj-wl-drawer");