From 3294bc202193111ac2228180c00245a2aff9aceb Mon Sep 17 00:00:00 2001 From: bot-backend Date: Sun, 31 May 2026 21:33:23 +0000 Subject: [PATCH] fix(tradein): exclude novostroyki from radius-median comp pool (#935) Co-authored-by: bot-backend Co-committed-by: bot-backend --- 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 931c1d15..1a89d419 100644 --- a/tradein-mvp/backend/app/services/estimator.py +++ b/tradein-mvp/backend/app/services/estimator.py @@ -3246,6 +3246,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 @@ -3594,6 +3598,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