fix(tradein): renumber obj_class migration to 121 + drop no-op DISTINCT ON (#572)

- 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)
This commit is contained in:
Light1YT 2026-05-28 18:58:08 +05:00
parent dfae54384e
commit 39f390ddb8
2 changed files with 5 additions and 3 deletions

View file

@ -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"типов", "Типовой"),
]

View file

@ -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,