gendesign/backend/tests/integration
Light1YT c336f91182
All checks were successful
CI / changes (pull_request) Successful in 6s
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m50s
CI / backend-tests (pull_request) Successful in 11m17s
fix(site-finder): align competitor flats_sold to objective_lots.contract_date (#1926)
Audit #1871/#1926: competitor block computed flats_sold from
domrf_kn_flats.status (LIKE '%прод%'/'sold'), populated in only ~0.2% of
rows (99.8% NULL) -> massive undercount (~1600 units in reported case) and
divergence from MarketMetrics, which counts sold via objective_lots.contract_date
(100% populated for sold lots).

Fix: new _SOLD_COUNT_SQL counts sold lots from objective_lots.contract_date
IS NOT NULL, bridged domrf obj_id -> objective_complex_mapping.domrf_obj_id ->
objective_complex_mapping.objective_complex_name == objective_lots.project_name
(same 1:1 mapping pattern as _OBJECTIVE_PRICE_FALLBACK_SQL primary_price CTE).
This is the exact source MarketMetrics._STOCK_SQL uses, so the two paths agree.
Dropped the domrf_kn_flats.status count from _AVG_PRICE_SQL (price-only now).

No schema/Pydantic field change (flats_sold/sold_pct already existed) ->
codegen not needed. psycopg v3 CAST style preserved.

Tests: updated mock DB ordering (+ sold-count execute), added
test_competitors_flats_sold_from_contract_date (120/200 -> 60% sold) and
phantom-column EXPLAIN check for _SOLD_COUNT_SQL.
2026-06-26 23:03:13 +05:00
..
__init__.py test(infra): integration phantom column gate (#197) (#216) 2026-05-16 13:07:13 +00:00
conftest.py test(infra): integration phantom column gate (#197) (#216) 2026-05-16 13:07:13 +00:00
test_analyze_parcels_sql.py test(parcels): integration EXPLAIN-gate для analyze hot-path SQL (#1198) 2026-06-13 09:43:49 +05:00
test_phantom_columns.py fix(site-finder): align competitor flats_sold to objective_lots.contract_date (#1926) 2026-06-26 23:03:13 +05:00