fix(tradein): backfill kn obj_class (parser + 3-pass) (#572) #628

Merged
Light1YT merged 2 commits from fix/572-kn-obj-class-backfill into main 2026-05-28 15:04:32 +00:00

2 commits

Author SHA1 Message Date
39f390ddb8 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)
2026-05-28 18:58:08 +05:00
dfae54384e fix(domrf): backfill kn obj_class via aiDescription + older snapshots (#572)
kn-API /kn/object endpoint never populates objClass (0/1516 objects confirmed
in bug-22a audit). Parser _extract_obj_class_from_ai() worked but lacked the
"типов" pattern, missing "типового класса"/"типовой серии" in 131+ objects.
The 2026-05-24 sweep was also truncated (1 object in raw payload) leaving 620
new rows with no aiDescription to extract from.

Fix:
- Add (r"типов", "Типовой") to _OBJ_CLASS_PATTERNS in domrf_kn.py; aligns with
  the "Типовой" value that domrf_catalog.py (SSR scraper) already sets from pages.
- Migration 120: three-pass backfill covering all snapshots:
  Pass 1: aiDescription from all stored raw payloads with extended pattern
  Pass 2: propagate obj_class forward from most recent older snapshot (covers
          broken 2026-05-24 sweep — 185 objects)
  Pass 3: objective_complex_mapping → objective_lots modal class (~14 objects)
  Projects 50.2% → 71.2% coverage (3819→5418/7614 rows); meets ≥70% acceptance.
2026-05-28 18:48:31 +05:00