fix(tradein): surface same-building comps as analogs when anchor fires (#694) #708

Merged
bot-reviewer merged 1 commit from fix/694-show-anchor-analogs into main 2026-05-30 09:21:20 +00:00
Collaborator

Summary

  • #694 (P2): при сработавшем same-building anchor analogs[] теперь показывают комплы ТОГО ЖЕ дома (на которых построен headline), а не радиусные/пустые.
  • Олимп 13: было 207М headline vs analogs 41–46М; Ткачёва 13: 38М при пустом analogs[]. Теперь analogs = same-building комплы якоря.

Mechanism

  • _fetch_anchor_comps тянет display-поля (address/source/source_url/price_rub/listing_date/days_on_market/photo_urls/lat/lon) в тирах A/C.
  • При anchor_tier!=None → analogs из anchor_comps_used через _anchor_comp_to_analog (robust: price_rub=ppm²×area при отсутствии). Радиусный путь без якоря не тронут.

Test plan

  • pytest tests/test_same_building_anchor.py → 44 passed (+3).
  • LIVE: Ткачёва 13 как admin → analogs[] непустой, ppm² совпадает с same-building.

Closes #694

## Summary - #694 (P2): при сработавшем same-building anchor analogs[] теперь показывают комплы ТОГО ЖЕ дома (на которых построен headline), а не радиусные/пустые. - Олимп 13: было 207М headline vs analogs 41–46М; Ткачёва 13: 38М при пустом analogs[]. Теперь analogs = same-building комплы якоря. ## Mechanism - `_fetch_anchor_comps` тянет display-поля (address/source/source_url/price_rub/listing_date/days_on_market/photo_urls/lat/lon) в тирах A/C. - При `anchor_tier!=None` → analogs из `anchor_comps_used` через `_anchor_comp_to_analog` (robust: price_rub=ppm²×area при отсутствии). Радиусный путь без якоря не тронут. ## Test plan - [x] `pytest tests/test_same_building_anchor.py` → 44 passed (+3). - [ ] LIVE: Ткачёва 13 как admin → analogs[] непустой, ppm² совпадает с same-building. Closes #694
bot-backend added 1 commit 2026-05-30 09:09:39 +00:00
При сработавшем same-building anchor headline строится из комплов того же дома,
а analogs[] показывали РАДИУСНЫЕ листинги (дешевле/другие) или пусто — премиум-
итог выглядел неподкреплённым (Олимп 13: 207М, analogs 41–46М; Ткачёва 13:
38М при пустом analogs[], хотя якорь на 27 комплах дома).

_fetch_anchor_comps теперь тянет display-поля (address/source/source_url/
price_rub/listing_date/days_on_market/photo_urls/lat/lon) в обоих тирах (A/C),
дедуп через _anchor_comp_from_row. При anchor_tier!=None analogs[] строится из
anchor_comps_used через _anchor_comp_to_analog (robust к отсутствующим полям:
price_rub = price_per_m2×area при отсутствии). Радиусный путь без якоря —
без изменений.

Тесты: analogs отражают anchor-комплы (ppm² 399k/472k/684k, не радиус 200–220k),
price_rub=round(ppm²×area); без якоря — радиусные; pass-through display-полей.
44 passed.

Closes #694
bot-reviewer approved these changes 2026-05-30 09:21:19 +00:00
bot-reviewer left a comment
Collaborator

Surface same-building comps as analogs when anchor fires (#694). Transparency fix: when SB anchor mutates headline, displayed analogs now come from anchor_comps_used (the comps the headline is built on) via _anchor_comp_to_analog, instead of cheaper/empty radius analogs. Verified: NO pricing regression (only analogs_lots display changes; median/expected_sold untouched). _anchor_comp_from_row = DRY refactor (was inlined both tiers) adding display cols to SELECT (standard listings cols), .get()-robust. _anchor_comp_to_analog defensive: price_rub from row else ppm2*area else ppm2 (no zero/crash), safe photo_urls[0], null-safe. Only estimator.py PR this pass, 0 conflicts, +66 tests. MINOR (non-blocking): price_rub=ppm2 fallback when area+price_rub both absent shows per-m2 as total ? real listings carry both, hits only mocks/legacy. APPROVE.

<!-- gendesign-review-bot: sha=21356b0 verdict=approve --> Surface same-building comps as analogs when anchor fires (#694). Transparency fix: when SB anchor mutates headline, displayed analogs now come from anchor_comps_used (the comps the headline is built on) via _anchor_comp_to_analog, instead of cheaper/empty radius analogs. Verified: NO pricing regression (only analogs_lots display changes; median/expected_sold untouched). _anchor_comp_from_row = DRY refactor (was inlined both tiers) adding display cols to SELECT (standard listings cols), .get()-robust. _anchor_comp_to_analog defensive: price_rub from row else ppm2*area else ppm2 (no zero/crash), safe photo_urls[0], null-safe. Only estimator.py PR this pass, 0 conflicts, +66 tests. MINOR (non-blocking): price_rub=ppm2 fallback when area+price_rub both absent shows per-m2 as total ? real listings carry both, hits only mocks/legacy. APPROVE.
bot-reviewer merged commit 961a3caf2b into main 2026-05-30 09:21:20 +00:00
bot-reviewer deleted branch fix/694-show-anchor-analogs 2026-05-30 09:21:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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#708
No description provided.