diff --git a/src/api/project_routes.py b/src/api/project_routes.py index 0b53d51..098b0c3 100644 --- a/src/api/project_routes.py +++ b/src/api/project_routes.py @@ -21,6 +21,19 @@ def _registry() -> ProjectRegistry: async def list_projects(): reg = _registry() projects = reg.list_projects() + # 实时统计每个项目的任务数 + from src.blackboard.db import Blackboard + from pathlib import Path + for pid, info in projects.items(): + if info.get("status") in ("archived", "deleted"): + continue + db_path = Path(reg.root) / pid / "blackboard.db" + if db_path.exists(): + try: + bb = Blackboard(db_path) + info['task_count'] = bb.count_tasks() + except Exception: + pass return {"projects": {pid: info for pid, info in projects.items() if info.get("status") not in ("archived", "deleted")}}