feat(project): dashboard workload by assignee with subtasks and completion

Replace the scheduled-tasks bar chart with a table of all tasks assigned
per person in scope (no due date needed, filters ignored): main tasks,
subtasks (new GET /api/projects/{id}/subtasks-summary), done counts and
completion rate, plus a total row. Admin only, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 14:09:06 +09:00
parent c766af691a
commit fc3a2d0b9b
14 changed files with 247 additions and 26 deletions
+30
View File
@@ -684,6 +684,36 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
const d = env.d;
check("[프로젝트 줄] 읽기 전용은 연결 목록만 표시", d.getElementById("pj-link-form").hidden && d.getElementById("pj-links-block").classList.contains("is-readonly") && !!d.querySelector(".pj-link-chip") && !d.querySelector(".pj-link-del"));
}
// ── 대시보드 담당자별 작업 합계 — 메인·하위 분리, 완료 수, 마감일 없어도 포함, 다른 범위 하위 작업 제외 ──
{
const env = makeEnv(); baseRoutes(env);
env.d.querySelector(".pj-project-view").dataset.isAdmin = "true";
let asked = null;
env.route("GET", /\/project\/api\/projects\/1\/subtasks-summary\?scope=project$/, function (u) {
asked = u;
return { body: { subtasks: [
{ parent_task_id: 101, assignee_email: "me@test.local", assignee_name: "Me", done: true },
{ parent_task_id: 101, assignee_email: "bob@test.local", assignee_name: "Bob", done: false },
{ parent_task_id: 103, assignee_email: "bob@test.local", assignee_name: "Bob", done: true }, // 다른 프로젝트 작업의 하위
] } };
});
const P = await boot(env);
P.state().tasks.forEach(function (t) {
if (t.id === 101) Object.assign(t, { assignee_email: "me@test.local", assignee_name: "Me", completed_at: "2026-09-29T10:00:00+09:00" });
if (t.id === 102) Object.assign(t, { assignee_email: "me@test.local", assignee_name: "Me" });
if (t.id === 301) Object.assign(t, { assignee_email: "bob@test.local", assignee_name: "Bob" });
});
env.d.querySelector('.pj-tab[data-view="dashboard"]').click(); await settle();
const rows = Array.from(env.d.querySelectorAll(".pj-wl-table tbody tr")).map(function (tr) {
return Array.from(tr.children).slice(0, 4).map(function (c) { return c.textContent.trim(); }).join("|");
});
const totalRow = env.d.querySelector(".pj-wl-total");
const total = totalRow ? totalRow.textContent.replace(/\s+/g, " ") : "";
check("[대시보드 담당자별] 하위 작업 요청(이 프로젝트 범위)", !!asked);
check("[대시보드 담당자별] 사람별 메인·하위·전체(마감일 없는 작업 포함, 다른 프로젝트 하위 제외)",
JSON.stringify(rows) === JSON.stringify(["Me|2|1|3", "Bob|1|1|2"]), rows);
check("[대시보드 담당자별] 합계 줄 완료 2/5 (40%) — 메인 완료 1 + 하위 완료 1", /2 \/ 5 40%/.test(total), total);
}
clearTimeout(WATCHDOG);
console.log(fails.length ? "\nFAILED: " + fails.join(", ") : "\nALL PASS");
process.exit(fails.length ? 1 : 0);
+63
View File
@@ -0,0 +1,63 @@
"""대시보드 담당자별 작업 합계 — 하위 작업 요약 API(subtasks-summary) 범위·권한. DB 없이 가짜 저장소로."""
import importlib
import unittest
from types import SimpleNamespace
from unittest.mock import patch
from fastapi import FastAPI, HTTPException
from fastapi.testclient import TestClient
api = importlib.import_module("app.modules.project.router")
class FakeStore:
def __init__(self):
self.asked_projects, self.asked_parents = None, None
def list_projects(self, include_archived, member_email):
return [{"id": 1, "parent_id": None}, {"id": 2, "parent_id": None}, {"id": 5, "parent_id": 1}]
def list_tasks_for_projects(self, project_ids):
self.asked_projects = project_ids
return [{"id": 10 * pid} for pid in project_ids]
def list_subtasks_of(self, parent_ids):
self.asked_parents = parent_ids
return [{"parent_task_id": parent_ids[0], "assignee_email": "a@test", "assignee_name": "A", "done": True}]
class SubtaskSummaryTests(unittest.TestCase):
def setUp(self):
app = FastAPI()
app.include_router(api.router)
self.client = TestClient(app)
self.st = FakeStore()
def call(self, scope):
with patch.object(api, "_require_user", return_value={"email": "me@test"}), \
patch.object(api, "_db_or_503", return_value=self.st), \
patch.object(api, "_require_manage", return_value=None), \
patch.object(api, "_accessible_project_ids", return_value=None):
return self.client.get(f"/project/api/projects/1/subtasks-summary?scope={scope}")
def test_project_scope_uses_only_this_project(self):
r = self.call("project")
self.assertEqual(r.status_code, 200, r.text)
self.assertEqual(self.st.asked_projects, [1])
self.assertEqual(self.st.asked_parents, [10])
self.assertEqual(r.json()["subtasks"][0]["done"], True)
def test_all_scope_uses_top_level_projects(self):
self.call("all")
self.assertEqual(self.st.asked_projects, [1, 2]) # 서브프로젝트(5) 제외 — 스냅샷과 같은 범위
def test_no_access_is_rejected(self):
with patch.object(api, "_require_user", return_value={"email": "me@test"}), \
patch.object(api, "_db_or_503", return_value=self.st), \
patch.object(api, "_require_manage", side_effect=HTTPException(403)):
self.assertEqual(self.client.get("/project/api/projects/1/subtasks-summary").status_code, 403)
self.assertIsNone(self.st.asked_parents)
if __name__ == "__main__":
unittest.main()