feat(project): 홈 화면 프로젝트 카드에 업무 미리보기·진행률 표시

카드마다 완료/전체 진행률 바와 미완료 업무 목록(담당자·마감일, 최대 8건)을
붙여 프로젝트 전체 현황을 홈에서 한눈에 볼 수 있게 함.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 08:42:28 +09:00
parent 32cc8299e3
commit 78683a9ae4
4 changed files with 96 additions and 2 deletions
+31
View File
@@ -339,6 +339,36 @@ async def index(request: Request) -> HTMLResponse:
# 완료된 프로젝트는 비활성으로 맨 끝에 (홈 카드 정렬). 안정 정렬.
projects = sorted(projects, key=lambda p: 1 if p.get("status") == "completed" else 0)
tree = _build_tree(projects)
# 아바타 맵: 이메일(소문자) → 구글 프로필 이미지 URL (홈 카드 업무 담당자 표시용)
from app.main import user_store # noqa: WPS433
avatars = {
store.norm_str(u["email"], lower=True): u.get("picture") or ""
for u in user_store.list_all()
if u.get("picture")
}
# 프로젝트 카드에 업무 미리보기(담당자·마감일·진행률) 붙이기 — 한눈에 현황 파악용
today_iso = today_kst().isoformat()
for p in tree:
p_tasks = st.list_tasks(project_id=p["id"], include_subprojects=True, limit=500)
total = len(p_tasks)
done = sum(1 for t in p_tasks if t.get("completed_at"))
open_tasks = [t for t in p_tasks if not t.get("completed_at")]
open_tasks.sort(key=lambda t: (t.get("due_date") is None, t.get("due_date") or "", t["id"]))
for t in open_tasks:
t["assignee_display"] = (
t.get("assignee_name")
or (t["assignee_email"].split("@")[0] if t.get("assignee_email") else "")
)
d = t.get("due_date")
t["due_overdue"] = bool(d and d[:10] < today_iso)
p["task_total"] = total
p["task_done"] = done
p["task_percent"] = round(done * 100 / total) if total else 0
p["task_preview"] = open_tasks[:8]
p["task_more"] = max(0, len(open_tasks) - 8)
my_tasks = st.list_tasks(assignee_email=user["email"], limit=500)
# 내 업무를 프로젝트별로 묶어 트리로 표시
my_groups: dict[int, dict[str, Any]] = {}
@@ -366,6 +396,7 @@ async def index(request: Request) -> HTMLResponse:
"page_subtitle": "달력·타임라인·보드로 프로젝트를 관리하세요.",
"tree": tree,
"my_projects": my_projects,
"avatars": avatars,
"today": today_kst().isoformat(),
},
)