[moz] fix(api): Review M1 修复 — expand=all 保持旧格式 + _toolchain 加入 _VIRTUAL_PROJECTS
- M1: expand=all 保持旧 list 格式(向后兼容 TaskModal .map()/.length)
- 细粒度 expand=comments,events 用新 {items,total_count,limit} 格式
- S1(PR#73): _toolchain 加入 _VIRTUAL_PROJECTS
- S1(PR#72): 移除 _validate_project 未使用 import
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ from src.blackboard.registry import ProjectRegistry
|
|||||||
from src.utils import get_data_root
|
from src.utils import get_data_root
|
||||||
|
|
||||||
# 虚拟项目白名单
|
# 虚拟项目白名单
|
||||||
_VIRTUAL_PROJECTS = frozenset({"_general", "_mail"})
|
_VIRTUAL_PROJECTS = frozenset({"_general", "_mail", "_toolchain"})
|
||||||
|
|
||||||
|
|
||||||
def _validate_project(project_id: str) -> str:
|
def _validate_project(project_id: str) -> str:
|
||||||
|
|||||||
+20
-3
@@ -55,10 +55,27 @@ async def get_task(project_id: str, task_id: str,
|
|||||||
if not expand:
|
if not expand:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
expand_list = expand.split(",") if expand != "all" else [
|
# expand=all: 保持旧格式(list + 聚合字段),向后兼容前端 TaskModal
|
||||||
"comments", "outputs", "reviews", "events", "decisions"
|
if expand == "all":
|
||||||
]
|
q = _q(project_id)
|
||||||
|
detail = q.task_detail(task_id)
|
||||||
|
if detail:
|
||||||
|
result["comments_count"] = detail.get("comments_count", 0)
|
||||||
|
result["outputs_count"] = detail.get("outputs_count", 0)
|
||||||
|
result["review_status"] = detail.get("review_status")
|
||||||
|
result["latest_event_detail"] = detail.get("latest_event_detail")
|
||||||
|
result["comments"] = [dict(c.__dict__)
|
||||||
|
for c in bb.get_comments(task_id)]
|
||||||
|
result["outputs"] = [dict(o.__dict__) for o in bb.get_outputs(task_id)]
|
||||||
|
result["reviews"] = [dict(r.__dict__) for r in bb.get_reviews(task_id)]
|
||||||
|
result["decisions"] = [dict(d.__dict__)
|
||||||
|
for d in bb.get_decisions(task_id)]
|
||||||
|
result["events"] = q.task_events(task_id)
|
||||||
|
result["experiences"] = q.task_experiences(task_id)
|
||||||
|
return result
|
||||||
|
|
||||||
|
# 细粒度 expand: 新格式(comments/events 带 limit + total_count)
|
||||||
|
expand_list = expand.split(",")
|
||||||
q = _q(project_id)
|
q = _q(project_id)
|
||||||
|
|
||||||
if "comments" in expand_list:
|
if "comments" in expand_list:
|
||||||
|
|||||||
Reference in New Issue
Block a user