gendesign/backend/app
Light1YT 7533bc333b
All checks were successful
CI / frontend-tests (pull_request) Has been skipped
CI / openapi-codegen-check (pull_request) Successful in 1m55s
CI / changes (pull_request) Successful in 7s
CI / backend-tests (pull_request) Successful in 12m10s
fix(site_finder): correct best-layouts supply fan-out + objects-first perf
domrf_kn_objects is a snapshot dimension (UNIQUE (obj_id, snapshot_date), ~8
snapshots/obj_id). _SUPPLY_BATCH_SQL joined flats to ALL object-snapshot rows
(no o.snapshot_date filter), counting each flat ~8.5x → supply_units_in_radius
inflated ~8.5x, sold_pct_of_supply deflated ~8.5x, is_oversold under-fired
(all user-facing, best_layouts.py:571-611; sold_pct=deals/supply is a raw
ratio so no canceling).

Fix: dedup objects to one row per obj_id (latest-snapshot coords) via
DISTINCT ON in an objects-first MATERIALIZED CTE, then join domrf_kn_flats via
idx_kn_flats_obj. units now = one count per flat (prod cross-check at radius
1.5km: units == count(*) == count(DISTINCT f.id) == 9612 for 65 objects;
correction factor 8.56x at 1.5km, 9.13x at 1.0km). This also aligns the supply
denominator with the deals numerator (_COMPETITORS_IN_RADIUS_SQL already uses
DISTINCT ON latest snapshot).

Perf bonus: objects-first avoids the parallel seq scan of the ~376k-row flats
snapshot. radius 1.5km / snapshot 2026-05-17: 240ms/~28k buffers/6712 disk
reads -> 49ms/1554 buffers/0 disk reads (~5x).

Tests: add SQL-text fan-out guard (DISTINCT ON + MATERIALIZED, no bare
flats->objects join); update stale EXPLAIN mirror in test_phantom_columns.

USER-FACING: best-layouts supply/sold_pct/is_oversold/sell-out-months shift
~8.5x toward correct (frontend BestLayoutsBlock only; ТЗ recommendation + PDF
unchanged — they derive from sum_deals, not supply). Deep-reviewed (APPROVE).
2026-06-27 10:45:19 +05:00
..
api feat(analyze): per-category OSRM routing (foot vs driving) (#39 A3) 2026-06-27 04:30:25 +05:00
core feat(analyze): per-category OSRM routing (foot vs driving) (#39 A3) 2026-06-27 04:30:25 +05:00
models merge: resolve conflicts with main (#1660) into week-review-finish 2026-06-17 20:21:06 +03:00
observability feat(backend): sentry-sdk init для FastAPI + Celery (#204 backend) (#207) 2026-05-16 15:09:16 +00:00
schemas feat(site-finder): OSM engineering-networks loader + endpoint (#1746) (#1930) 2026-06-26 20:01:00 +00:00
scrapers fix(week-review): backend-аудит v2 — 82 фиксов (#1660) 2026-06-17 17:13:38 +00:00
services fix(site_finder): correct best-layouts supply fan-out + objects-first perf 2026-06-27 10:45:19 +05:00
templates fix(site-finder): 5 дефектов из боевого фидбека analyze (#1736 #1737 #1738 #1739 #1740) 2026-06-18 11:47:21 +05:00
workers feat(site-finder): OSM engineering-networks loader + endpoint (#1746) (#1930) 2026-06-26 20:01:00 +00:00
__init__.py init 2026-04-25 13:45:19 +03:00
main.py fix(backend): emit app.* INFO logs to stdout on the API process (#1926) 2026-06-27 07:43:49 +05:00