feat(tradein): recurring house-dedup merge (schedule dormant) (#1772) #1933
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1933
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/1772-recurring-house-merge"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Recurring house-dedup merge (#1772)
One physical building splits into multiple
housesrows → same-building comps lost. Migration108_merge_duplicate_houses.sqldid a ONE-TIME merge, but duplicates recur (the matching pipeline keeps creating them: Tier-3 geo-jitter + per-source ext_id INSERTs). A migration can't fix a steady-state inflow → this is a RECURRING, idempotent, collision-safe merge.Reuses 108's proven collision-safe pattern
cluster → canonical keeper → re-point children with UNIQUE-collision handling → delete losers → backfill sources/aliases, all in ONE transaction.houses.address— cadastral_number is 100% NULL on prod (migration 040), so address is the real building key.REFERENCES housesagainst the live schema; same 11 children as 108, none added after):listings.house_id_fk,house_placement_history,house_reviews,house_reliability_checks,external_valuations→ plain re-point (no blocking UNIQUE)house_sourcesUNIQUE(ext_source,ext_id) → delete colliding losers, re-point resthouse_address_aliasesUNIQUE(normalized_address) → delete colliding, re-point resthouses_price_dynamics→ dedup by the LIVE 6-col UNIQUE (house_id, source, room_count, prices_type, period, month_date) — migration 029 replaced 108's stale 3-col key; deduping on the old key would still violate on re-pointhouse_imv_evaluationsUNIQUE(house_id) → dedup, re-pointhouse_suggestionsUNIQUE(house_id,ext_item_id) → dedup, re-pointaddress_mismatch_auditUNIQUE(house_id,audit_batch) → dedup, re-pointSchedule DISABLED by default (deploy neutral)
Migration
135seedsscrape_scheduleshouse_dedup_mergeenabled=false (DORMANT). This is an auto-recurring DESTRUCTIVE merge — deploy stays neutral. The orchestrator dry-runs + does one validated manual run, then enables deliberately.dry_run + idempotent
dry_run=Truecomputes counts then ROLLBACK (no writes).Verify
uv run pytest -k "dedup or merge or house" -q→ 25 passed, 1 skipped (real-DB test self-skips).uv run ruff checkclean on all changed files.Files
app/services/house_dedup_merge.py(service + run-lifecycle wrapper)app/services/scheduler.py(trigger + dispatch + docstring)data/sql/135_scrape_schedules_seed_house_dedup_merge.sql(seed, enabled=false)tests/test_house_dedup_merge.py