Просмотр исходного кода

feat:无执行中任务是不推送

jihuaqiang 3 дней назад
Родитель
Сommit
9a88e907ee
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      scheduler/decode_hourly_stats_job.py

+ 10 - 0
scheduler/decode_hourly_stats_job.py

@@ -230,6 +230,16 @@ def run_decode_hourly_stats_job() -> None:
         pending = stats["pending"]
         running = stats["running"]
         fail = stats["fail"]
+        executed_in_window = success + running + fail
+        if executed_in_window <= 0:
+            logger.info(
+                "当前统计窗口无已执行任务,跳过推送 window=[{}, {}) total={} pending={}",
+                window_start.strftime("%Y-%m-%d %H:%M:%S"),
+                window_end.strftime("%Y-%m-%d %H:%M:%S"),
+                total,
+                pending,
+            )
+            return
         fail_rate = (fail / total) if total > 0 else 0.0
         success_rate = (success / total) if total > 0 else 0.0
         today_stats = _fetch_today_stats(now)