From 14bcb2122198eec81a465484008baa411fe82a11 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Mon, 1 Jun 2026 00:21:35 +0300 Subject: [PATCH] fix(tradein): exclude novostroyki from radius-median comp pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Основной estimator-путь (Tier S/H/W через _COMMON_WHERE) не фильтровал сегмент → новостройки (девелоперский прайс) подмешивались в comps вторички → завышение медианы ₽/м². Добавлен фильтр (listing_segment IS NULL OR <> 'novostroyki') в _COMMON_WHERE + Tier W inline. Tier C уже segment-aware. --- tradein-mvp/backend/app/services/estimator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tradein-mvp/backend/app/services/estimator.py b/tradein-mvp/backend/app/services/estimator.py index ba0e9d3a..de5a3f1c 100644 --- a/tradein-mvp/backend/app/services/estimator.py +++ b/tradein-mvp/backend/app/services/estimator.py @@ -3081,6 +3081,10 @@ _COMMON_WHERE = """ OR year_built BETWEEN CAST(:cohort_year_min AS integer) AND CAST(:cohort_year_max AS integer) ) + -- Исключаем новостройки из comp-пула вторички: девелоперский прайс искажает + -- медиану ₽/м². NULL сегмент пропускаем (rosreestr/avito/yandex без сегмента — + -- это вторичка или неклассифицированный объект). + AND (listing_segment IS NULL OR listing_segment <> 'novostroyki') """ # Note: Tier W has its own inline copy of the cohort clause (PR #519 line # ~1280). Не удалять — Tier W не использует _COMMON_WHERE из-за inline @@ -3429,6 +3433,9 @@ def _fetch_analogs( OR year_built BETWEEN CAST(:cohort_year_min AS integer) AND CAST(:cohort_year_max AS integer) ) + -- Tier W: исключаем новостройки из comp-пула (sync с _COMMON_WHERE). + -- NULL сегмент пропускаем — rosreestr/avito/yandex без сегмента вторичка. + AND (listing_segment IS NULL OR listing_segment <> 'novostroyki') -- 2026-05-23: Avito coords теперь real (PR #487 убрал jitter после -- C-5 audit). Listings с NULL coords отфильтруются через ST_DWithin -- (geom IS NULL → не matches). geocode-missing-listings backfill -- 2.45.3