35 lines
1.6 KiB
Plaintext
35 lines
1.6 KiB
Plaintext
# test_task_state.dspy - 查看任务 km--pJq8 的状态
|
|
|
|
pid = 'T_2hWHTqqwgf8igNMHLQk'
|
|
tid = 'km--pJq85fFBoG6ftzCHT'
|
|
|
|
dbname = get_module_dbname('pipeline-sdlc')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
task = await sor.sqlExe(
|
|
"SELECT id, title, role, state, claimed_by, params FROM pipeline_tasks WHERE id=${tid}$",
|
|
{"tid": tid})
|
|
|
|
# 所有 review/waiting 状态任务
|
|
stuck = await sor.sqlExe(
|
|
"SELECT id, title, role, state FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state IN ('review','waiting','running') ORDER BY created_at DESC",
|
|
{"pid": pid})
|
|
|
|
# PM review 交付件
|
|
deliv = await sor.sqlExe(
|
|
"SELECT id, deliverable_type, review_status FROM pipeline_deliverables WHERE task_id=${tid}$ ORDER BY created_at DESC LIMIT 5",
|
|
{"tid": tid})
|
|
|
|
result = {
|
|
"task": [{"id": getattr(t,'id',''), "title": getattr(t,'title',''),
|
|
"role": getattr(t,'role',''), "state": getattr(t,'state',''),
|
|
"claimed_by": getattr(t,'claimed_by',''),
|
|
"params": getattr(t,'params','')[:200]} for t in (task or [])],
|
|
"stuck_tasks": [{"id": getattr(t,'id','')[:12], "title": getattr(t,'title','')[:40],
|
|
"role": getattr(t,'role',''), "state": getattr(t,'state','')}
|
|
for t in (stuck or [])],
|
|
"deliverables": [{"id": getattr(d,'id','')[:12], "type": getattr(d,'deliverable_type',''),
|
|
"review": getattr(d,'review_status','')} for d in (deliv or [])],
|
|
}
|
|
|
|
return json.dumps(result, ensure_ascii=False, default=str)
|