From 5b44086c8a6a899a9b43b9190ab8a027eb02a059 Mon Sep 17 00:00:00 2001 From: hmo Date: Mon, 20 Jul 2026 23:58:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20reports=E5=8C=B9=E9=85=8D=E9=93=BE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3(=E6=A0=87=E9=A2=98=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=98=AF=E6=AD=BB=E4=BB=A3=E7=A0=81)=20+=20s?= =?UTF-8?q?trategy=5Fhistory=E7=A9=BA=E5=8E=86=E5=8F=B2=E6=97=B6=E9=99=8D?= =?UTF-8?q?=E7=BA=A7=E5=BD=93=E5=89=8D=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server.py b/server.py index 451c4cc5..b76e5666 100644 --- a/server.py +++ b/server.py @@ -230,6 +230,8 @@ def api_strategy_history(code): LIMIT ? """, (code, limit)).fetchall() history = [dict(r) for r in rows] + if not history: + raise LookupError("history empty, fallback to current row") except Exception: # 表不存在或查询失败 → 降级为当前 holding_strategies 行 history = [] @@ -306,8 +308,11 @@ def api_reports(): for f in sorted(reports_dir.iterdir(), reverse=True): if f.suffix != ".json": continue + data = _load_json(f) if (cron_key or script_key) else None if cron_key or script_key: stem = f.stem + title = str(data.get("title", "")) + # 命中链:job id 前缀 → 名/脚本子串(文件名) → pipeline名子串(标题) hit = False if job_id and stem.startswith(f"cron_{job_id}_"): hit = True @@ -315,18 +320,12 @@ def api_reports(): hit = True elif script_key and script_key in stem: hit = True + elif cron_key and cron_key in title: + hit = True if not hit: continue - data = _load_json(f) - # 最后兜底:pipeline名出现在报告标题里也算匹配 - if (cron_key or script_key) and cron_key: - title = str(data.get("title", "")) - stem = f.stem - if not (job_id and stem.startswith(f"cron_{job_id}_")) \ - and cron_key not in stem \ - and not (script_key and script_key in stem) \ - and cron_key not in title: - continue + if data is None: + data = _load_json(f) reports.append({ "id": f.stem, "title": data.get("title", f.stem),