feat(tradein-estimator): tiered house-match S→H→W #507

Merged
lekss361 merged 3 commits from feat/tradein-house-match-tiered into main 2026-05-24 12:41:13 +00:00

3 commits

Author SHA1 Message Date
lekss361
8e0e80cf58 fix(tradein-estimator): address review-bot items on PR #507
- _extract_short_addr handles Свердловская область / Россия / г. prefixes,
  drops trailing кв./корп./оф., anchors on street keywords (ул./пр./пер./…)
- Tier S ORDER BY scraped_at DESC (was constant relevance_score=0.0)
- Drop ext_house_id kwarg (column never existed on listings table)
- 7 unit tests for _extract_short_addr covering real address formats

Closes 4 deferred items from gendesign-review-bot fa43ea8 review.
2026-05-24 15:36:15 +03:00
lekss361
fa43ea8dc8 fix(tradein-estimator): ruff lint fixes (RUF046, E501) pre-existing in #507
- Remove redundant int() around round() — RUF046
- Wrap long f-strings in _compute_confidence to stay within 100 chars
- Simplify photo_url expression in _listing_to_analog
2026-05-24 15:00:22 +03:00
lekss361
c4f1978ed0 feat(tradein-estimator): tiered house-match S→H→W (same-house, class, wide)
Currently year/house_type only influence relevance sort. For a 17-эт. 1975
building we returned 5-9 эт. брежневки as analogs.

Three tiers:
- S (same building): address ILIKE prefix, ≥3 → return only these
- H (same class): year ±15, total_floors ±30%, ≥5 → return
- W (wide): current logic without year/floors WHERE filter

Tier propagated to confidence_explanation so user sees why analogs may differ.

Source: estimate a0a0b820-e8a8-4eee-aa73-0ab3b98ac233.
2026-05-24 14:59:45 +03:00