fix(merge): keep earliest created_at when merging scenes (no false NEW)

The NEW badge keys off scene.created_at. merge_scenes kept the survivor's created_at,
but the dedup caller may pick the freshly re-ingested mirror as keep_id — so deduplicated
old content got a recent created_at and showed up as NEW (report f17799b3). Coalesce to
min(keep, drop) so a merged scene keeps its first-seen date.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jtrzupek 2026-06-29 11:21:41 +02:00
parent b3ddb67ced
commit a5f355841a

View file

@ -221,6 +221,12 @@ def _coalesce_canonical_fields(keep: Scene, drop: Scene) -> None:
if drop.title and len(drop.title) > len(keep.title or ""):
keep.title = drop.title
keep.title_normalized = drop.title_normalized
# created_at = najwcześniejsze "first seen" obu scen. NEW badge (apka) bazuje na
# created_at; gdy dedup wybierze świeży re-ingest/mirror jako `keep`, stara treść
# dostawałaby fałszywe NEW po merdżu (report f17799b3). Bierzemy min → zdeduplikowana
# scena zachowuje datę pierwszego pojawienia, nie datę re-ingestu.
if drop.created_at and keep.created_at and drop.created_at < keep.created_at:
keep.created_at = drop.created_at
def _close_pending_candidates(