fix: create_task 默认归当前迭代(最新迭代);_resolve_iteration_id 取当前迭代而非第一个
This commit is contained in:
parent
6add7ff4fa
commit
7ec0fb611f
@ -34,6 +34,7 @@ SDL_TOOLS = [
|
|||||||
"title": "任务标题",
|
"title": "任务标题",
|
||||||
"role": "目标角色(requirement/design/develop/test/deploy)",
|
"role": "目标角色(requirement/design/develop/test/deploy)",
|
||||||
"description": "任务详细描述",
|
"description": "任务详细描述",
|
||||||
|
"iteration_id": "归属迭代(可选,默认当前迭代)",
|
||||||
},
|
},
|
||||||
category="task",
|
category="task",
|
||||||
),
|
),
|
||||||
@ -320,13 +321,27 @@ async def _h_create_task(sor, p, ctx):
|
|||||||
role = _normalize_role(role)
|
role = _normalize_role(role)
|
||||||
|
|
||||||
tid = getID()
|
tid = getID()
|
||||||
|
# 迭代归属:显式指定 > 当前迭代(该 project 最新创建的迭代)。
|
||||||
|
# 「当前迭代」概念:新建迭代后当前迭代即新建的那个,任务默认归到它。
|
||||||
|
iteration_name = (p.get("iteration_id", "") or "").strip()
|
||||||
|
if not iteration_name:
|
||||||
|
irecs = await sor.sqlExe(
|
||||||
|
"SELECT iteration_name FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at DESC LIMIT 1",
|
||||||
|
{"pid": pid})
|
||||||
|
if irecs:
|
||||||
|
iteration_name = getattr(irecs[0], 'iteration_name', '') or ''
|
||||||
|
|
||||||
|
params = {"description": desc}
|
||||||
|
if iteration_name:
|
||||||
|
params["iteration_id"] = iteration_name
|
||||||
|
|
||||||
await sor.C("pipeline_tasks", {
|
await sor.C("pipeline_tasks", {
|
||||||
"id": tid, "tenant_id": pid, "pipeline_id": "role_task",
|
"id": tid, "tenant_id": pid, "pipeline_id": "role_task",
|
||||||
"owner_id": ctx.get("user_id") or "user", "title": title,
|
"owner_id": ctx.get("user_id") or "user", "title": title,
|
||||||
"state": "submitted", "role": role,
|
"state": "submitted", "role": role,
|
||||||
"params": json.dumps({"description": desc}, ensure_ascii=False),
|
"params": json.dumps(params, ensure_ascii=False),
|
||||||
})
|
})
|
||||||
return f"OK: 已创建任务 {title}(角色: {role})"
|
return f"OK: 已创建任务 {title}(角色: {role},迭代: {iteration_name or '未分配'})"
|
||||||
|
|
||||||
|
|
||||||
async def _h_list_tasks(sor, p, ctx):
|
async def _h_list_tasks(sor, p, ctx):
|
||||||
@ -819,7 +834,7 @@ async def _resolve_iteration_id(sor, pid, iteration_id):
|
|||||||
return full, ""
|
return full, ""
|
||||||
return "", f"迭代不存在: {iteration_id}"
|
return "", f"迭代不存在: {iteration_id}"
|
||||||
recs = await sor.sqlExe(
|
recs = await sor.sqlExe(
|
||||||
"SELECT id FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at ASC LIMIT 1",
|
"SELECT id FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at DESC LIMIT 1",
|
||||||
{"pid": pid})
|
{"pid": pid})
|
||||||
if recs:
|
if recs:
|
||||||
return getattr(recs[0], "id", ""), ""
|
return getattr(recs[0], "id", ""), ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user