fix(22j): DEDUP domrf_kn_infrastructure + ON CONFLICT (issue #297) #304
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#304
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/22j-dedup-v3"
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?
Audit numbers (postgres MCP)
(obj_id, poi_category, poi_name, poi_address)Root cause
Старый
ON CONFLICT (obj_id, poi_name, poi_lat, poi_lon, snapshot_date) DO UPDATE—snapshot_dateв ключе → каждый scrape run вставлял новые строки вместо UPDATE → накопление ×N (N = количество scrape runs).Changes
data/sql/110_22j_dedup_infrastructure.sqlDELETEkeepingmin(ctid)per(obj_id, poi_category, poi_name, poi_address)DROP CONSTRAINT domrf_kn_infrastructure_obj_id_poi_name_poi_lat_poi_lon_sna_key(old wrong granularity, idempotent skip if absent)ADD CONSTRAINT uq_infra_dedupe UNIQUE NULLS NOT DISTINCT (obj_id, poi_category, poi_name, poi_address)(PG16, handles nullable poi_category/poi_address)backend/app/services/scrapers/domrf_kn.pyUPSERT_INFRA_SQL— ON CONFLICT key matches new constraint,DO NOTHING(POI fields immutable, нет смысла update'ить):Deploy order
data/sql/110_22j_dedup_infrastructure.sqlfirst (auto через_schema_migrations).Verify
Related: issue #297 sub-task 22j
Deep Code Review — verdict: APPROVE
Pre-merge checks
state=open,mergeable=true, base=main, head=7863a99domrf_kn_infrastructure_obj_id_poi_name_poi_lat_poi_lon_sna_key— exact match с DROP в миграцииidx_infra_obj,idx_infra_cat_dist— оба переживут)(obj_id, poi_name, poi_lat, poi_lon, snapshot_date)108 → (109/110 reserved) → 110_22j (THIS) → 111_22f → 112_22ifixes/Fix_BUG22j_Infrastructure_Dedup_May17.mdуже созданаUPSERT_INFRA_SQLcolumns точно совпадают с новым UNIQUE —(obj_id, poi_category, poi_name, poi_address)✓Cross-file impact
DO NOTHINGкорректно (subtitle/distance_m не критичны для пересмотра)EXPLAIN на DELETE (cost estimate)
_schema_migrationsэто переживёт, downstream scrapers просто подождутMinor nits (non-blocking)
100_22j_dedup_infrastructure.sql(унаследовано из vault draft), фактическое имя файла110_22j_*— расхождение в комментарии, не влияет на executionDO NOTHING(вместоDO UPDATEдля distance_m) — если POI «переедет» (новый адрес или категория переименуется на DOM.РФ) — будет вставлена новая строка как другой логический POI, старая останется. Это acceptable per task scope, но flag для будущего monitoringDestructive note
Approved — merging via squash.