diff --git a/mailer.py b/mailer.py index 1eba98f..5813e1f 100644 --- a/mailer.py +++ b/mailer.py @@ -254,6 +254,35 @@ def collect_report_data() -> dict: # ── 活跃作业 ── jobs_active = JobInfo.query.filter_by(snapshot_id=latest.id).order_by(JobInfo.job_index).all() + # Z1 详细输出把作业信息存在 DomainDetail 里, 若 JobInfo 为空则从 DomainDetail 回退 + if not jobs_active: + try: + from app import DomainDetail + domain_rows = DomainDetail.query.filter_by(snapshot_id=latest.id).all() + if domain_rows: + # 按 (owner, pid, design) 去重统计活跃作业数 + active_set = set() + for dr in domain_rows: + owner = dr.owner or "" + pid = dr.pid or "" + 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 "—")) + if active_set: + # 构造虚拟 job 对象供渲染 (兼容 jobs_active 格式) + class _VJob: + pass + for idx, (o, p, design, tpod) in enumerate(sorted(active_set), 1): + j = _VJob() + j.job_index = idx + j.owner = o + j.pid = p + j.t_pod = tpod + j.design = design + j.elap_time = "" + jobs_active.append(j) + except (ImportError, AttributeError): + pass + # ── 24h 统计 ── snaps_24h = ScanSnapshot.query.filter( ScanSnapshot.timestamp >= cutoff_24h @@ -543,10 +572,8 @@ def _render_html(data: dict, base_url: str) -> str: f'