同步本地更改

This commit is contained in:
2025-12-15 10:48:58 +08:00
parent dab29347bd
commit a619e96e73
3 changed files with 139 additions and 13 deletions

View File

@@ -91,8 +91,18 @@ def compute_next_run_at(
if random_delay:
window_start = candidate_base - timedelta(minutes=15)
random_minutes = random.randint(0, 30)
candidate = window_start + timedelta(minutes=random_minutes)
window_end = candidate_base + timedelta(minutes=15)
# 只从“未来窗口”中抽样,避免抽到过去时间导致整天被跳过
delta_seconds = (now - window_start).total_seconds()
if delta_seconds < 0:
min_offset = 0
else:
min_offset = int(delta_seconds // 60) + 1
max_offset = int((window_end - window_start).total_seconds() // 60)
if min_offset > max_offset:
continue
candidate = window_start + timedelta(minutes=random.randint(min_offset, max_offset))
else:
candidate = candidate_base
@@ -110,4 +120,3 @@ def format_cst(dt: datetime) -> str:
dt = BEIJING_TZ.localize(dt)
dt = dt.astimezone(BEIJING_TZ)
return dt.strftime("%Y-%m-%d %H:%M:%S")