Spaces:
Paused
Paused
zt p commited on
Commit ·
ebdd50a
1
Parent(s): 552bc71
Skip TMS summary on startup day
Browse files- pages/📨 排片检查与 TMS 内容核对监控.py +13 -6
pages/📨 排片检查与 TMS 内容核对监控.py
CHANGED
|
@@ -41,6 +41,7 @@ WEEKDAY_NAMES = ["周一", "周二", "周三", "周四", "周五", "周六", "
|
|
| 41 |
MISSING_ISSUE_TYPES = {"missing_assert12", "missing_assert_id"}
|
| 42 |
MAX_RETRY_ATTEMPTS = 3
|
| 43 |
RETRY_DELAY_SECONDS = 300
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
class RetryableAPIError(RuntimeError):
|
|
@@ -957,6 +958,8 @@ def run_daily_check(run_date, logger):
|
|
| 957 |
|
| 958 |
class DailyTMSSummaryMonitor:
|
| 959 |
def __init__(self):
|
|
|
|
|
|
|
| 960 |
self.logs = deque(maxlen=100)
|
| 961 |
self.status_text = "未完成"
|
| 962 |
self.next_run_str = "--"
|
|
@@ -1050,17 +1053,21 @@ class DailyTMSSummaryMonitor:
|
|
| 1050 |
|
| 1051 |
def _run_loop(self):
|
| 1052 |
self.log("🕤 排片检查与 TMS 内容核对监控已启动")
|
| 1053 |
-
last_loop_time =
|
| 1054 |
|
| 1055 |
while True:
|
| 1056 |
try:
|
| 1057 |
now = get_beijing_now()
|
| 1058 |
today_str = now.strftime("%Y-%m-%d")
|
| 1059 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1060 |
last_loop_time = now
|
| 1061 |
state = load_monitor_state()
|
| 1062 |
self.last_state = state
|
| 1063 |
-
today_run_time = datetime.combine(now.date(),
|
| 1064 |
|
| 1065 |
if state.get("last_completed_date") != today_str and should_run_today:
|
| 1066 |
self._execute_today_check()
|
|
@@ -1069,10 +1076,10 @@ class DailyTMSSummaryMonitor:
|
|
| 1069 |
|
| 1070 |
if state.get("last_completed_date") == today_str:
|
| 1071 |
self.status_text = "已完成"
|
| 1072 |
-
next_run_dt = datetime.combine(now.date() + timedelta(days=1),
|
| 1073 |
-
elif now >= today_run_time:
|
| 1074 |
self.status_text = "等待下次固定时间"
|
| 1075 |
-
next_run_dt = datetime.combine(now.date() + timedelta(days=1),
|
| 1076 |
else:
|
| 1077 |
self.status_text = "未完成"
|
| 1078 |
next_run_dt = today_run_time
|
|
|
|
| 41 |
MISSING_ISSUE_TYPES = {"missing_assert12", "missing_assert_id"}
|
| 42 |
MAX_RETRY_ATTEMPTS = 3
|
| 43 |
RETRY_DELAY_SECONDS = 300
|
| 44 |
+
DAILY_RUN_TIME = dt_time(9, 55)
|
| 45 |
|
| 46 |
|
| 47 |
class RetryableAPIError(RuntimeError):
|
|
|
|
| 958 |
|
| 959 |
class DailyTMSSummaryMonitor:
|
| 960 |
def __init__(self):
|
| 961 |
+
self.started_at = get_beijing_now()
|
| 962 |
+
self.startup_skip_date = self.started_at.strftime("%Y-%m-%d")
|
| 963 |
self.logs = deque(maxlen=100)
|
| 964 |
self.status_text = "未完成"
|
| 965 |
self.next_run_str = "--"
|
|
|
|
| 1053 |
|
| 1054 |
def _run_loop(self):
|
| 1055 |
self.log("🕤 排片检查与 TMS 内容核对监控已启动")
|
| 1056 |
+
last_loop_time = self.started_at
|
| 1057 |
|
| 1058 |
while True:
|
| 1059 |
try:
|
| 1060 |
now = get_beijing_now()
|
| 1061 |
today_str = now.strftime("%Y-%m-%d")
|
| 1062 |
+
is_startup_skip_day = today_str == self.startup_skip_date
|
| 1063 |
+
should_run_today = (
|
| 1064 |
+
not is_startup_skip_day
|
| 1065 |
+
and did_cross_fixed_time(last_loop_time, now, DAILY_RUN_TIME)
|
| 1066 |
+
)
|
| 1067 |
last_loop_time = now
|
| 1068 |
state = load_monitor_state()
|
| 1069 |
self.last_state = state
|
| 1070 |
+
today_run_time = datetime.combine(now.date(), DAILY_RUN_TIME)
|
| 1071 |
|
| 1072 |
if state.get("last_completed_date") != today_str and should_run_today:
|
| 1073 |
self._execute_today_check()
|
|
|
|
| 1076 |
|
| 1077 |
if state.get("last_completed_date") == today_str:
|
| 1078 |
self.status_text = "已完成"
|
| 1079 |
+
next_run_dt = datetime.combine(now.date() + timedelta(days=1), DAILY_RUN_TIME)
|
| 1080 |
+
elif is_startup_skip_day or now >= today_run_time:
|
| 1081 |
self.status_text = "等待下次固定时间"
|
| 1082 |
+
next_run_dt = datetime.combine(now.date() + timedelta(days=1), DAILY_RUN_TIME)
|
| 1083 |
else:
|
| 1084 |
self.status_text = "未完成"
|
| 1085 |
next_run_dt = today_run_time
|