fix: 已删除设备残留失败记录不再出现在异常汇总
- _merge_status 清理不在 STF 设备池且无运行 worker 的陈旧状态 - /api/summary 按当前设备池过滤,STF 异常时不隐藏任何记录
This commit is contained in:
@@ -723,6 +723,16 @@ class TaskManager:
|
||||
worker_status = {w["serial"]: w for w in get_all_worker_status()}
|
||||
running = self.get_running()
|
||||
|
||||
# 清理陈旧状态:serial 已不在 STF 设备池、且没有在跑 worker 的条目,
|
||||
# 避免设备被删除后其失败记录仍残留在"异常汇总"里
|
||||
present = {dev.get("serial", "") for dev in all_devices}
|
||||
for serial, w in list(worker_status.items()):
|
||||
if serial in present or serial in running:
|
||||
continue
|
||||
if w.get("status") in ("running", "connecting"):
|
||||
continue
|
||||
_remove_worker(serial)
|
||||
|
||||
result = []
|
||||
for dev in all_devices:
|
||||
serial = dev.get("serial", "")
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user