fix: 修复 answer_question/add_bug/list_questions/diagnose 的 DB 列名错误

- 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(查项目默认迭代)
This commit is contained in:
ymq 2026-08-13 17:27:41 +08:00
parent 094d66d42b
commit 49338b4fc7

View File

@ -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}"