auto-sync: 2026-05-21 08:16:52
This commit is contained in:
@@ -21,9 +21,9 @@ def _registry() -> ProjectRegistry:
|
||||
async def list_projects():
|
||||
reg = _registry()
|
||||
projects = reg.list_projects()
|
||||
# 实时统计每个项目的任务数
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
# 实时统计每个项目的任务数
|
||||
for pid, info in projects.items():
|
||||
if info.get("status") in ("archived", "deleted"):
|
||||
continue
|
||||
@@ -36,6 +36,29 @@ async def list_projects():
|
||||
info['task_count'] = count
|
||||
except Exception:
|
||||
pass
|
||||
# 虚拟项目 _general:如果 blackboard.db 存在则插入
|
||||
general_db = Path(reg.root) / "_general" / "blackboard.db"
|
||||
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]
|
||||
conn.close()
|
||||
projects["_general"] = {
|
||||
"id": "_general", "name": "一般任务", "description": "无项目归属的通用任务",
|
||||
"status": "active", "source": "virtual", "task_count": count,
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
elif "_general" in projects:
|
||||
general_db_check = Path(reg.root) / "_general" / "blackboard.db"
|
||||
if general_db_check.exists():
|
||||
try:
|
||||
conn = sqlite3.connect(str(general_db_check), timeout=5)
|
||||
count = conn.execute("SELECT COUNT(*) FROM tasks").fetchone()[0]
|
||||
conn.close()
|
||||
projects["_general"]["task_count"] = count
|
||||
except Exception:
|
||||
pass
|
||||
return {"projects": {pid: info for pid, info in projects.items()
|
||||
if info.get("status") not in ("archived", "deleted")}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user