feat(my_todos): 待办列表补项目名(project_name),前端卡片显示所属项目

This commit is contained in:
ymq 2026-08-25 14:17:25 +08:00
parent aa9ca542ca
commit 6e28214a4e

View File

@ -1,4 +1,4 @@
# my_todos.dspy - 我的待办(跨项目:人类任务 + bug 验收 + 冒泡问题)
# my_todos.dspy - 我的待办(跨项目:人类任务 + bug 验收 + 冒泡问题)→ JSON
user_id = await get_user()
if not user_id:
@ -6,4 +6,23 @@ if not user_id:
todos = await list_my_human_todos(user_id)
# 补项目名
dbname = get_module_dbname('pipeline-sdlc')
proj_names = {}
for t in todos:
pid = t.get('project_id', '')
if pid and pid not in proj_names:
proj_names[pid] = pid
try:
async with DBPools().sqlorContext(dbname) as sor:
_pr = await sor.sqlExe("SELECT name FROM sd_projects WHERE id=${pid}$", {"pid": pid})
await sor.sqlExe("COMMIT", {})
if _pr:
proj_names[pid] = getattr(_pr[0], 'name', '') or pid
except Exception:
pass
t['project_name'] = proj_names.get(pid, pid)
else:
t['project_name'] = proj_names.get(pid, pid)
return json.dumps({"success": True, "todos": todos}, ensure_ascii=False, default=str)