fix: 活跃作业回退统计补充 elap_time + 过滤 T-Pod 占位符
Z1 从 DomainDetail 回退活跃作业时, 之前只统计了 owner/pid/design/t_pod, 漏了 elap_time (运行时间)。现在一并提取, 并过滤 '--' 占位符。
This commit is contained in:
@@ -261,24 +261,30 @@ def collect_report_data() -> dict:
|
|||||||
domain_rows = DomainDetail.query.filter_by(snapshot_id=latest.id).all()
|
domain_rows = DomainDetail.query.filter_by(snapshot_id=latest.id).all()
|
||||||
if domain_rows:
|
if domain_rows:
|
||||||
# 按 (owner, pid, design) 去重统计活跃作业数
|
# 按 (owner, pid, design) 去重统计活跃作业数
|
||||||
active_set = set()
|
active_set = {} # key: (owner, pid) -> {design, t_pod, elap_time}
|
||||||
for dr in domain_rows:
|
for dr in domain_rows:
|
||||||
owner = dr.owner or ""
|
owner = dr.owner or ""
|
||||||
pid = dr.pid or ""
|
pid = dr.pid or ""
|
||||||
if owner and owner not in ("NONE", "") and pid and pid not in ("0", ""):
|
if owner and owner not in ("NONE", "") and pid and pid not in ("0", ""):
|
||||||
active_set.add((owner, pid, dr.design or "—", dr.t_pod or "—"))
|
key = (owner, pid)
|
||||||
|
if key not in active_set:
|
||||||
|
active_set[key] = {
|
||||||
|
"design": dr.design or "—",
|
||||||
|
"t_pod": dr.t_pod or "—",
|
||||||
|
"elap_time": dr.elap_time or "—",
|
||||||
|
}
|
||||||
if active_set:
|
if active_set:
|
||||||
# 构造虚拟 job 对象供渲染 (兼容 jobs_active 格式)
|
# 构造虚拟 job 对象供渲染 (兼容 jobs_active 格式)
|
||||||
class _VJob:
|
class _VJob:
|
||||||
pass
|
pass
|
||||||
for idx, (o, p, design, tpod) in enumerate(sorted(active_set), 1):
|
for idx, ((o, p), info) in enumerate(sorted(active_set.items()), 1):
|
||||||
j = _VJob()
|
j = _VJob()
|
||||||
j.job_index = idx
|
j.job_index = idx
|
||||||
j.owner = o
|
j.owner = o
|
||||||
j.pid = p
|
j.pid = p
|
||||||
j.t_pod = tpod
|
j.t_pod = info["t_pod"] if "--" not in info["t_pod"] and info["t_pod"] not in ("—",) else "—"
|
||||||
j.design = design
|
j.design = info["design"]
|
||||||
j.elap_time = ""
|
j.elap_time = info["elap_time"] if info["elap_time"] not in ("—", "") else "—"
|
||||||
jobs_active.append(j)
|
jobs_active.append(j)
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user