From 39f390ddb805895a0403f62a7e31d2c8467b8c36 Mon Sep 17 00:00:00 2001 From: Light1YT Date: Thu, 28 May 2026 18:58:08 +0500 Subject: [PATCH] fix(tradein): renumber obj_class migration to 121 + drop no-op DISTINCT ON (#572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - git mv 120_backfill_obj_class_kn_api.sql → 121 (120 taken by kn_price_per_m2 on main) - Update header comment and RAISE NOTICE message to reference 121 - Pass 2 subquery: remove DISTINCT ON (obj_id, snapshot_date) — CROSS JOIN LATERAL with LIMIT 1 already guarantees one row per pair; DISTINCT ON was misleading - domrf_kn.py: add one-line note that r"типов" pattern is intentionally broad given DOM.RF aiDescription inflection variety (tightening risks <70% coverage) --- backend/app/services/scrapers/domrf_kn.py | 2 ++ ...j_class_kn_api.sql => 121_backfill_obj_class_kn_api.sql} | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) rename data/sql/{120_backfill_obj_class_kn_api.sql => 121_backfill_obj_class_kn_api.sql} (98%) diff --git a/backend/app/services/scrapers/domrf_kn.py b/backend/app/services/scrapers/domrf_kn.py index 9ac62623..22c15ba0 100644 --- a/backend/app/services/scrapers/domrf_kn.py +++ b/backend/app/services/scrapers/domrf_kn.py @@ -143,6 +143,8 @@ _OBJ_CLASS_PATTERNS: list[tuple[str, str]] = [ # that use the word "типов*" to describe standard/economy housing. The canonical value # "Типовой" matches what the catalog SSR scraper (domrf_catalog.py) extracts from pages. # Bug #572: this pattern was absent → 131+ objects remained NULL despite matching aiDescription. + # Intentionally broad (r"типов" not r"типов[ыоа]й?\b"): DOM.RF aiDescription uses varied + # inflections; tightening risks dropping coverage below the 70% acceptance threshold. (r"типов", "Типовой"), ] diff --git a/data/sql/120_backfill_obj_class_kn_api.sql b/data/sql/121_backfill_obj_class_kn_api.sql similarity index 98% rename from data/sql/120_backfill_obj_class_kn_api.sql rename to data/sql/121_backfill_obj_class_kn_api.sql index 4b58d65d..94b659ea 100644 --- a/data/sql/120_backfill_obj_class_kn_api.sql +++ b/data/sql/121_backfill_obj_class_kn_api.sql @@ -1,4 +1,4 @@ --- 120_backfill_obj_class_kn_api.sql +-- 121_backfill_obj_class_kn_api.sql -- -- Backfill obj_class for domrf_kn_objects rows that remain NULL after migration 106. -- @@ -75,7 +75,7 @@ WHERE o.obj_id = src.obj_id UPDATE domrf_kn_objects AS o SET obj_class = prev.obj_class FROM ( - SELECT DISTINCT ON (n.obj_id, n.snapshot_date) + SELECT n.obj_id, n.snapshot_date, best.obj_class @@ -145,7 +145,7 @@ BEGIN WHERE snapshot_date = v_latest_snap AND region_cd = 66; RAISE NOTICE - 'domrf_kn_objects after 120 backfill:' + 'domrf_kn_objects after 121 backfill:' ' all-snapshots: total=% filled=% null=%' ' | latest snapshot (%): total=% filled=%', v_total, v_filled, v_null,