From 49338b4fc79c33f0e1412193907c983778e1649a Mon Sep 17 00:00:00 2001 From: ymq Date: Thu, 13 Aug 2026 17:27:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20answer=5Fquestion/a?= =?UTF-8?q?dd=5Fbug/list=5Fquestions/diagnose=20=E7=9A=84=20DB=20=E5=88=97?= =?UTF-8?q?=E5=90=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - answer_question: answered=1 → status='answered'(表无answered列) - list_questions: answered IS NULL → status='pending' - diagnose_project: 问题计数 answered IS NULL → status='pending' - add_bug: 补 iteration_id(查项目默认迭代) --- pipeline_service/agent_loop_v2.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index 87205fb..68077f4 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -757,11 +757,11 @@ class AgentExecutor: review = await sor.sqlExe( "SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='review'", {"pid": pid}) - # questions 表可能没有 answered 列,用 try/except 兜底 + # questions 表可能没有 answered 列,用 status='pending' 兜底 qc = 0 try: questions = await sor.sqlExe( - "SELECT COUNT(*) as c FROM pipeline_agent_questions WHERE tenant_id=${pid}$ AND answered IS NULL", + "SELECT COUNT(*) as c FROM pipeline_agent_questions WHERE tenant_id=${pid}$ AND status='pending'", {"pid": pid}) qc = getattr(questions[0], "c", 0) if questions else 0 except Exception: @@ -844,10 +844,10 @@ class AgentExecutor: try: recs = await sor.sqlExe( "SELECT id, question, answer_source FROM pipeline_agent_questions " - "WHERE tenant_id=${pid}$ AND answered IS NULL ORDER BY created_at DESC LIMIT 10", + "WHERE tenant_id=${pid}$ AND status='pending' ORDER BY created_at DESC LIMIT 10", {"pid": pid}) except Exception: - # 兼容无 answered 列的情况 + # 兼容无 status 列的情况 try: recs = await sor.sqlExe( "SELECT id, question, answer_source FROM pipeline_agent_questions " @@ -881,7 +881,7 @@ class AgentExecutor: qid = getattr(recs[0], "id", qid) await sor.sqlExe( - "UPDATE pipeline_agent_questions SET answered=1, answer=${a}$ WHERE id=${qid}$", + "UPDATE pipeline_agent_questions SET answer=${a}$, status='answered' WHERE id=${qid}$", {"a": answer, "qid": qid}) return "OK: 已回答" @@ -962,10 +962,21 @@ class AgentExecutor: if not title: return "需要Bug标题" + # 找项目的迭代(iteration_id 必填) + iteration_id = p.get("iteration_id", "") + if not iteration_id: + its = await sor.sqlExe( + "SELECT id FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at ASC LIMIT 1", + {"pid": pid}) + if its: + iteration_id = getattr(its[0], "id", "") + if not iteration_id: + return "ERROR: 项目无迭代,无法提交Bug" + await sor.C("sd_bugs", { "id": getID(), "title": title, "description": desc, "severity": severity, - "status": "open", + "status": "open", "iteration_id": iteration_id, }) return f"OK: 已提交Bug: {title}"