fix: _open_qc_type_tasks的LIKE通配符用拼接构造——%格式化与SQL通配符冲突致对账器每轮崩溃(实测15秒一报)

This commit is contained in:
yumoqing 2026-09-02 18:14:07 +08:00
parent ab60afc018
commit de0b070e24

View File

@ -159,11 +159,12 @@ async def _dim_qc_improvements(sor, project_id, dim):
async def _open_qc_type_tasks(sor, project_id, qc_type):
"""某类型在办 QC 审核任务数params.qc_types 含该类型)。"""
kw = '%"qc_types": ["' + qc_type + '"]%' # 拼接构造SQL 里 % 是 LIKE 通配符,不能用 % 格式化
recs = await sor.sqlExe(
"SELECT COUNT(*) AS c FROM pipeline_tasks WHERE tenant_id=${p}$ "
"AND pipeline_id='role_task' AND role=${r}$ AND state IN "
"('submitted','running','review','qc_review') AND params LIKE ${kw}$",
{"p": project_id, "r": R_QC, "kw": '%"qc_types": ["%s"]%' % qc_type})
{"p": project_id, "r": R_QC, "kw": kw})
await sor.sqlExe("COMMIT", {})
return to_int(getattr(recs[0], "c", 0) if recs else 0)