feat(scheduler): 每周日05:00全量对齐job(四消息实体--full-history,修撤回/编辑+消除滞后窗口)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-21 13:52:59 +08:00
parent 0a161c7b6a
commit 621c2cc929
2 changed files with 40 additions and 3 deletions
+13 -3
View File
@@ -416,10 +416,10 @@ async def test_start_registers_two_jobs_with_expected_triggers(engine, session_m
with patch.object(scheduler_module, "AsyncIOScheduler", return_value=spy):
await sched.start()
# Two jobs registered.
assert spy.add_job.call_count == 2
# Three jobs registered (2026-08-21 加每周全量对齐).
assert spy.add_job.call_count == 3
job_ids = {c.kwargs["id"] for c in spy.add_job.call_args_list}
assert job_ids == {"yunke_full_sync", "yunke_message_sync"}
assert job_ids == {"yunke_full_sync", "yunke_message_sync", "yunke_weekly_full_history"}
# Full sync -> CronTrigger(hour=3); messages -> IntervalTrigger(hours=6).
# add_job was called as (func, trigger, kwargs...) so trigger is args[1].
@@ -444,6 +444,16 @@ async def test_start_registers_two_jobs_with_expected_triggers(engine, session_m
assert msg_call.args[0].__name__ == "_safe_page_run"
assert msg_call.kwargs["args"] == ["messages"]
# Weekly full-history: Sunday 05:00 CronTrigger.
weekly_call = next(
c for c in spy.add_job.call_args_list if c.kwargs["id"] == "yunke_weekly_full_history"
)
weekly_trigger = weekly_call.args[1]
assert "day_of_week='sun'" in str(weekly_trigger)
assert "hour='5'" in str(weekly_trigger) or "hour='5'" in repr(weekly_trigger)
assert weekly_call.args[0].__name__ == "_safe_page_run"
assert weekly_call.kwargs["args"] == ["full-history"]
# coalesce=True + max_instances=1 protects against overlap.
for c in spy.add_job.call_args_list:
assert c.kwargs["coalesce"] is True