fix: 已删除设备残留失败记录不再出现在异常汇总

- _merge_status 清理不在 STF 设备池且无运行 worker 的陈旧状态
- /api/summary 按当前设备池过滤,STF 异常时不隐藏任何记录
This commit is contained in:
2026-08-09 08:04:57 +08:00
parent 0c4f586ae5
commit 5f914c4fe4
2 changed files with 19 additions and 0 deletions
+9
View File
@@ -158,6 +158,15 @@ def api_summary():
"""
try:
sts = get_all_worker_status()
# 已删除/不在当前 STF 设备池的设备,其陈旧失败记录不应展示。
# 复用 get_status 缓存(顺带触发上面的状态清理),STF 异常时不隐藏任何记录。
try:
devices, derr = mgr.get_status()
if not derr:
present = {d.get("serial") for d in devices}
sts = [s for s in sts if s.get("serial") in present]
except Exception:
pass
counts = {"total": 0, "running": 0, "done": 0,
"error": 0, "failed": 0, "idle": 0}
errors = []