fix(cian): recover new-build house via cadastral anchor + listings (source,source_id) dedup (#1773) #1912
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1912
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/cian-address-anchor-1773"
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?
Адреса убивают same-building anchor. Два независимых фикса (PART 1 + 2; avito «29р-н» слип — отдельно, не тут).
PART 1 — cian new-build house recovery: когда
geo.address[]без{type:"house"}и это новостройка → восстанавливаем номер: (a)building.houseNumber/address, (c) хвост изnewbuilding.name, и КЛЮЧЕВОЕ —building_cadastral_numberкак same-building anchor key (cian_building_cad→ Tier-0 cadastr_exact), чтобы дробящиеся корпуса (6679/11110/7019) схлопывались даже без номера дома. Без фабрикации catch-all.PART 2 — dedup:
data/sql/133— partial UNIQUElistings(source, source_id) WHERE source_id IS NOT NULL. Существующие дубли (cian 330047129) дедуплицируются ДО constraint: keeper по(house_id_fk IS NOT NULL, is_active, last_seen_at, id), дети (price_history/snapshots/sources/valuations/merged_into) collision-safe пере-привязываются. Атомарно, идемпотентно, guard на остаток. Провалидировано на throwaway PG 16.save_listingsON CONFLICT (dedup_hash) совместим (не менял).+6 тестов (new-build house-less fixture). 259 cian-тестов passed, ruff clean. Refs #1773
PART 1 — cian-новостройки теряли номер дома: geo.address[] для ЖК часто без части {type:"house"}, адрес выходил house-less («…улица Евгения Савкова» без «29») и раздробленные корпуса схлопывались в catch-all → same-building anchor рвался. Теперь для новостроек без house восстанавливаем номер по приоритету: (a) building.houseNumber / building.address, (b) building_cadastral_number как anchor-ключ, (c) хвостовой дом-токен из newbuilding.name — без catch-all фабрикации. building_cadastral_number предпочтён как house anchor (house_source=cian_building_cad) → Tier 0 cadastr_exact схлопывает корпуса; nb_id остаётся fallback'ом. PART 2 — дубль-листинги: миграция 133 дедупит listings по (source, source_id) (keeper = house_id_fk → активность → свежесть → id), безопасно перепривязывает детей (price_history/snapshots/listing_sources/external_valuations/merged_into) collision-safe и вешает частичный UNIQUE (source, source_id) WHERE source_id IS NOT NULL. Идемпотентно, недеструктивно для keeper. save_listings оставлен на ON CONFLICT (dedup_hash) — арбитр согласован с новым constraint, source_id=NULL (yandex/url-only) не ломается. Refs #1773