Backfill guard: a past week's digest only takes papers published by its end

Backfilling an old week used to sweep in undigested papers published later
(stamping them into the wrong week and removing them from the next Monday's
digest); regular weekly runs are unaffected since the collection window
already ends at week_end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jsahn
2026-10-20 14:06:25 +09:00
co-authored by Claude Fable 5
parent 3f1d16cae1
commit cdd070749b
2 changed files with 17 additions and 0 deletions
+12
View File
@@ -84,6 +84,18 @@ def test_build_payload_invalid_feed_spec_is_a_gap(env):
assert any("invalid feed spec" in g for g in payload.data_gaps)
def test_backfill_excludes_papers_published_after_the_week(env):
# 과거 주 소급 생성: 그 주 이후에 발행된 미소화 논문은 과거 다이제스트로 끌려가면 안 된다
from datetime import date
in_week = make_paper("10.1/inweek", published_date=date(2026, 9, 2))
later = make_paper("10.1/later", published_date=date(2026, 9, 20)) # W36 이후 발행
undated = make_paper("10.1/undated", published_date=None)
env["store"].pending = [in_week, later, undated]
payload = build_payload(WEEK, env["settings"], env["store"]) # WEEK = 2026-W35 (…~09-06)
assert [p.doi for p in payload.papers] == ["10.1/inweek", "10.1/undated"]
def test_build_payload_caps_papers_and_notes_rollover(env):
env["store"].pending = [make_paper(f"10.1/p{i}") for i in range(5)]
env["settings"] = env["settings"].model_copy(update={"max_papers": 3})