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
+13
View File
@@ -484,6 +484,19 @@ class ProjectStore:
project_ids=[project_id], assignee_email=assignee_email, limit=limit,
)
def list_subtasks_of(self, *, parent_ids: list[int]) -> list[dict[str, Any]]:
"""하위 업무 요약(대시보드 담당자별 집계용) — 부모 id·담당자·완료 여부만."""
ids = sorted({int(i) for i in parent_ids})
if not ids:
return []
with self._pool.connection() as conn:
rows = conn.execute(
"SELECT parent_task_id, assignee_email, assignee_name, completed_at IS NOT NULL AS done "
"FROM tasks WHERE parent_task_id = ANY(%s)", (ids,),
).fetchall()
return [{"parent_task_id": int(r["parent_task_id"]), "assignee_email": r["assignee_email"] or "",
"assignee_name": r["assignee_name"] or "", "done": bool(r["done"])} for r in rows]
def list_tasks_for_projects(
self, *, project_ids: list[int], assignee_email: str | None = None,
limit: int = 20000,
+18
View File
@@ -1335,6 +1335,24 @@ def api_project_snapshot(request: Request, project_id: int, scope: str = "projec
})
@router.get("/api/projects/{project_id}/subtasks-summary")
def api_subtasks_summary(request: Request, project_id: int, scope: str = "project") -> JSONResponse:
"""대시보드 "담당자별 작업 합계" — 화면 업무 목록엔 하위 업무가 없어서(보드에 카드로 안 뜨게) 하위 업무만 따로.
scope=project → 이 프로젝트(+여기 연결된) 최상위 업무의 하위 업무, scope=all → 볼 수 있는 모든 최상위 프로젝트(스냅샷과 같은 범위)."""
user = _require_user(request)
st = _db_or_503(request)
_require_manage(request, st, user, project_id)
if scope == "all":
allowed = _accessible_project_ids(st, user)
ids = [p["id"] for p in st.list_projects(include_archived=False,
member_email=None if allowed is None else user["email"])
if not p.get("parent_id")]
else:
ids = [project_id]
parents = [t["id"] for t in st.list_tasks_for_projects(project_ids=ids)]
return JSONResponse({"subtasks": st.list_subtasks_of(parent_ids=parents)})
def _project_meta(p: dict[str, Any]) -> dict[str, Any]:
"""프로젝트 화면·스냅샷 공용 프로젝트 요약(사이드바·타임라인 그룹·보드 배지용)."""
return {
@@ -267,5 +267,5 @@
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project-meeting-cells.js?v=20261007a" defer></script>
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}
@@ -207,5 +207,5 @@
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}
@@ -407,7 +407,7 @@
<li>위쪽 숫자 카드 4개: <b>완료된 작업 합계 · 미완료 작업 합계 · 마감일이 지난 작업 합계 · 작업 합계</b></li>
<li><b>미완료 작업 합계(섹션별)</b> — 섹션마다 남은 일이 몇 개인지 막대로 보여줍니다. 막대에 마우스를 올리면 숫자가 나옵니다.</li>
<li><b>작업 합계(완료 상태별)</b> — 완료와 미완료 비율을 도넛 차트로 보여줍니다.</li>
<li><b>예정된 작업 합계(담당자별)</b> — 사람별로 일정이 잡힌 미완료 작업 수(상위 10명). <b>관리자에게만</b> 보입니다.</li>
<li><b>담당자별 작업 합계(메인·하위 작업, 완료)</b> — 이 범위에서 사람별로 배정된 작업 <b>전부</b>(마감일이 없어도, 필터와 관계없이)를 메인 작업·하위 작업으로 나눠 세고, 각각과 전체의 완료 수·완료율을 보여 줍니다. 하위 작업은 하위 작업에 지정된 담당자 기준입니다. 맨 아래 줄은 합계입니다. <b>관리자에게만</b> 보입니다.</li>
<li>범위(이 프로젝트/전체 프로젝트)와 필터 바 설정을 그대로 따라 계산합니다.</li>
</ul>
</section>
@@ -104,5 +104,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261004a" />
<link rel="stylesheet" href="/static/project.css?v=20261007a" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<!-- 타임라인 vis-timeline — self-host -->
@@ -492,5 +492,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261007e" defer></script>
<script src="/static/project.js?v=20261007f" defer></script>
{% endblock %}