From bd1ed4861ccabdc734584c363f81b18d4a8dea7b Mon Sep 17 00:00:00 2001 From: Light1YT Date: Sat, 27 Jun 2026 14:21:01 +0500 Subject: [PATCH] =?UTF-8?q?docs(zouit):=20=D1=83=D1=82=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20DISTINCT=20ON-=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B9=20+=20=D1=83=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D1=8C=20stale=20cad=5Fzouit=20=D0=B8=D0=B7?= =?UTF-8?q?=20FE-=D1=82=D0=B8=D0=BF=D0=B0=20(#1957)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code-review nits (без изменения поведения): - quarter_dump_lookup.py: комментарий про дедуп ошибочно утверждал, что зоны без рег-номера не схлопываются. На деле reg_numb_border — TEXT NOT NULL (0 NULL на проде), а DISTINCT ON в PG считает NULL равными. Переформулировано на точное. - frontend/types/nspd.ts: убран устаревший 'cad_zouit' из списка возможных group_key (бэкенд теперь эмитит только protected/engineering/okn/natural/other). --- backend/app/services/site_finder/quarter_dump_lookup.py | 5 +++-- frontend/src/types/nspd.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/app/services/site_finder/quarter_dump_lookup.py b/backend/app/services/site_finder/quarter_dump_lookup.py index 2ade90c2..dd493801 100644 --- a/backend/app/services/site_finder/quarter_dump_lookup.py +++ b/backend/app/services/site_finder/quarter_dump_lookup.py @@ -544,8 +544,9 @@ def _get_cad_zouit_overlaps(db: Session, parcel_wkt: str) -> list[dict[str, Any] # в ::geography для корректных м². NULLIF guard от деления на ноль → coverage None. # #1957: cad_zouit хранит одну физическую зону 2× (одинаковый reg_numb_border, # разный category_name) → дубль-строки в overlaps. DISTINCT ON (reg_numb_border) - # схлопывает в одну (берём наименьший id). Зоны без рег-номера (NULL) не - # схлопываются между собой — каждая остаётся отдельной строкой. + # схлопывает в одну, оставляя наименьший id (ORDER BY reg_numb_border, id). + # reg_numb_border — TEXT NOT NULL (0 NULL на проде), так что рег-номер есть у + # каждой строки и дедуп идёт по реальному идентификатору зоны. rows = db.execute( text( """ diff --git a/frontend/src/types/nspd.ts b/frontend/src/types/nspd.ts index 0f7001ff..bc0d84aa 100644 --- a/frontend/src/types/nspd.ts +++ b/frontend/src/types/nspd.ts @@ -19,7 +19,7 @@ export interface NspdZoning { } export interface NspdZouitOverlap { - group_key: string; // e.g. "engineering", "okn", "natural", "protected", "other", "cad_zouit" + group_key: string; // e.g. "engineering", "okn", "natural", "protected", "other" layer: string; // e.g. "zouit_engineering"; для cad_zouit fallback = type_zone subcategory: string | number | null; name: string | null;