gendesign/tradein-mvp/backend
Light1YT bcdc7ccb04
All checks were successful
CI / backend-tests (pull_request) Has been skipped
CI / changes (pull_request) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Has been skipped
fix(estimator): deterministic comp tie-breaker + n_analogs counts priced analogs
Found by adversarial valuation audit (2 confirmed, bot-safe).

FIX A (#5): both radius comp queries (Tier H ~3990, Tier W ~4135) ended with
a bare ORDER BY relevance_score; on score ties Postgres returned rows in
undefined order, so the same /analyze could pick different comps across runs.
Append deterministic tiebreaker: relevance_score ASC, distance_m ASC,
scraped_at DESC NULLS LAST, id ASC (id = listings PK → total order). Added id
to each base CTE; outer projection unchanged (no leak downstream).

FIX B (#2): _filter_outliers keeps rows with price_per_m2 IS NULL, but the
median is built from prices_ppm2 (drops them) while n_analogs counted all of
listings_clean — overstating contributing comps ("Найдено N аналогов"
misleading; all-price-less -> median=0 but n_analogs>0). Count n_analogs from
prices_ppm2 in the radius path. #698 anchor overwrite + #691 zero-analog->low
guard unaffected; listings_clean itself not filtered.

Adds tests/test_estimator_n_analogs_priced.py (verified to fail on old code).
Audit also flagged velocity fan-out (false-positive: 0 duplicate domrf_obj_id
on prod) and >/>= disclosure tweaks (cosmetic) — deliberately not changed.

Refs #1871
2026-06-27 05:57:04 +05:00
..
app fix(estimator): deterministic comp tie-breaker + n_analogs counts priced analogs 2026-06-27 05:57:04 +05:00
data/sql fix(tradein): backfill house_id_fk via source-identity path (#1781) 2026-06-27 05:01:02 +05:00
scripts fix(backfill): drop nonexistent kadastr_num column from listings SELECT 2026-06-17 23:47:30 +03:00
tests fix(estimator): deterministic comp tie-breaker + n_analogs counts priced analogs 2026-06-27 05:57:04 +05:00
.dockerignore feat: add tradein-mvp subproject (Trade-In Estimator под /trade-in) 2026-05-21 00:25:39 +03:00
Dockerfile feat(browser): split camoufox into tradein-browser container, connect-mode (#905) 2026-05-31 17:24:35 +03:00
pyproject.toml fix(scrapers/backend): socks5 health-probe (httpx[socks]) + status Literal whitelist + #1820 ext_id=0 dedup-гард 2026-06-20 10:17:37 +03:00