From c56bc577fae23442896236ac74fbeb459f23d31f Mon Sep 17 00:00:00 2001 From: cfdaily Date: Thu, 21 May 2026 08:27:50 +0800 Subject: [PATCH] auto-sync: 2026-05-21 08:27:50 --- src/api/project_routes.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/api/project_routes.py b/src/api/project_routes.py index 6c73cff..1c0ec95 100644 --- a/src/api/project_routes.py +++ b/src/api/project_routes.py @@ -45,11 +45,13 @@ async def list_projects(): if general_db.exists() and "_general" not in projects: try: conn = sqlite3.connect(str(general_db), timeout=5) - count = conn.execute("SELECT COUNT(*) FROM tasks").fetchone()[0] + total = conn.execute("SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0] + active = conn.execute("SELECT COUNT(*) FROM tasks WHERE status NOT IN ('cancelled','done') AND COALESCE(archived,0)=0").fetchone()[0] conn.close() projects["_general"] = { "id": "_general", "name": "一般任务", "description": "无项目归属的通用任务", - "status": "active", "source": "virtual", "task_count": count, + "status": "active", "source": "virtual", + "task_count": active, "task_count_total": total, "task_count_archived": total - active, } except Exception: pass @@ -58,9 +60,12 @@ async def list_projects(): if general_db_check.exists(): try: conn = sqlite3.connect(str(general_db_check), timeout=5) - count = conn.execute("SELECT COUNT(*) FROM tasks").fetchone()[0] + total = conn.execute("SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0] + active = conn.execute("SELECT COUNT(*) FROM tasks WHERE status NOT IN ('cancelled','done') AND COALESCE(archived,0)=0").fetchone()[0] conn.close() - projects["_general"]["task_count"] = count + projects["_general"]["task_count"] = active + projects["_general"]["task_count_total"] = total + projects["_general"]["task_count_archived"] = total - active except Exception: pass return {"projects": {pid: info for pid, info in projects.items()