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
Owner

Summary

  • Root cause: kn API never returns objClass (upstream-null) AND parser missed "типового класса/серии".
  • domrf_kn.py: added типов pattern to _OBJ_CLASS_PATTERNS.
  • Migration 121: 3-pass backfill (aiDescription / forward-propagate / objective_lots). Coverage 50%→~71%.
  • Complementary to migration 106 (does not duplicate).

Test plan

  • migration 121 applies
  • ≥70% EKB ЖК have obj_class

Closes #572

## Summary - Root cause: kn API never returns objClass (upstream-null) AND parser missed "типового класса/серии". - domrf_kn.py: added типов pattern to _OBJ_CLASS_PATTERNS. - Migration 121: 3-pass backfill (aiDescription / forward-propagate / objective_lots). Coverage 50%→~71%. - Complementary to migration 106 (does not duplicate). ## Test plan - [ ] migration 121 applies - [ ] ≥70% EKB ЖК have obj_class Closes #572
Light1YT added 2 commits 2026-05-28 13:58:27 +00:00
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.
- 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)
Light1YT merged commit 4e4762f234 into main 2026-05-28 15:04:32 +00:00
Light1YT deleted branch fix/572-kn-obj-class-backfill 2026-05-28 15:04:32 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#628
No description provided.