fix(daily_check): 期望窗口未到不应判 missed

work #07 (2026-07-03):daily_check 在日内运行时(如 09:00/12:00/15:00)
误把'还没到时间'的任务标 missed。SCHEDULE 里有 window_end 但 _classify_task
没用到——直接判 last_success vs today_start。

修复:判定 missed 之前先比较 now vs window_end;未到则返回 not_yet
(新状态,不进 alerts),已过但今日未成功走原 missed 路径。解析失败
回落旧逻辑不引入风险。

验证 4 个用例:12:00 kline_daily→not_yet, 18:00 kline_daily→missed,
18:00 longhubang→not_yet, 22:30 longhubang→missed。全部正确。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gao
2026-07-03 18:25:50 +08:00
parent b351bd7595
commit f7a2cbe5a8
2 changed files with 90 additions and 0 deletions
+23
View File
@@ -133,6 +133,28 @@ def _classify_task(
last_failure = _parse_ts(row.get("last_failure_at"))
status_field = row.get("status", "idle")
# 期望窗口是否已过?未到窗口不应判 missed
if spec and spec.get("window_end") and not status_field == "running":
try:
hh, mm = spec["window_end"].split(":")
window_end_dt = datetime.combine(check_date, datetime.min.time()).replace(
hour=int(hh), minute=int(mm)
)
if now < window_end_dt:
return {
"dataset_id": dataset_id,
"name": row.get("name", ""),
"status": "not_yet",
"reason": f"期望窗口 {spec['window_end']} 未到(now={now.strftime('%H:%M')}",
"last_success_at": row.get("last_success_at"),
"last_failure_at": row.get("last_failure_at"),
"last_error": row.get("last_error"),
"needs_resync": row.get("needs_resync", 0),
"status_field": status_field,
}
except (ValueError, AttributeError):
pass # 解析失败回落到旧逻辑
# 还在跑(卡死检测)
if status_field == "running":
started = _parse_ts(row.get("started_at"))
@@ -399,6 +421,7 @@ def print_summary(report: dict[str, Any]) -> None:
"running": "🔄",
"never_run": "",
"not_expected": "",
"not_yet": "",
"disabled": "🚫",
}.get(t["status"], "·")
print(f" {icon} [{t['status']:>13}] {t['dataset_id']:<20} {t['reason']}")