gendesign/backend/tests/api/v1
Light1YT 74f1ffb500
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 1m49s
CI / backend-tests (pull_request) Successful in 13m58s
perf(objective): request-path consumers dedup inline, not via whole-table view (#1964)
deep-review #1964: v_objective_lots_latest has NO premise/district filter inside,
so a consumer's outer WHERE cannot push below DISTINCT ON → the view materializes
the WHOLE table (Parallel Seq Scan + external Sort 1.76M rows, ~55MB spill) on
every query. For REQUEST-PATH consumers inside analyze_parcel this is a ~19x latency
regression vs the pre-#1964 raw-table plan.

DISPROVEN remedy (NOT applied): a full index on the physflat-key does NOT help —
DISTINCT ON selects ol.* (51 cols, width≈945) so index-only-unique is impossible;
the planner ignores the index (seq-scan+sort still cheaper) and even forced it is
~3.9 s. A 142MB index for zero request-path benefit + slower bulk-INSERT during
objective-scrape is wrong. Honors original #1964 decision "no new index".

Prod EXPLAIN (Академический / 3km radius, 2026-06-28):
  consumer            via view      inline (this commit)
  concepts median     5854 ms       1640 ms   (bitmap district + sort)
  parcels district    5854 ms       1640 ms
  parcels geo-median  6443 ms        122 ms   (NestedLoop geo->complex bitmap)
  parcels obj_pricing 5721 ms        441 ms   (project bitmap per nearby ЖК)

FIX: keep v_objective_lots_latest ONLY for batch/background/cached consumers
(supply_layers L1, competitors._SOLD_COUNT_SQL, special_indices [/forecast bg task
30-180s], admin, landing). Revert the 4 request-path consumers inside analyze_parcel
to inline DISTINCT ON (physflat-key, latest snapshot) with the filter pushed INTO the
CTE so the district/spatial/project index applies:
- concepts._OBJECTIVE_MEDIAN_SQL
- parcels.py district price block
- parcels.py geo-radius median (complex_id-scoped)
- parcels.py obj_pricing CTE (project_name-scoped; aggregates over deduped set)

Migration 175 header CORRECTED: accurately states the partial mig-173 index does NOT
serve the view (qual can't push below DISTINCT ON), the full index is disproven/not
added, and which consumers use the view vs inline. No DDL change (still view-only).

Tests: +guards (concepts/obj_pricing dedup inline, not view; obj_pricing physflat
DISTINCT ON; perf-pushdown scope preserved). 965 passed.
2026-06-28 05:00:47 +05:00
..
__init__.py feat(cadastre): bulk_harvest worker + grid-walker + admin API (#168 PR3/5) (#171) 2026-05-15 13:31:32 +03:00
conftest.py test(analyze): авто-стаб geoportal зон-резолвера в api/v1 тестах (CI desync fix) 2026-06-24 04:33:17 +05:00
test_admin_cadastre.py test(suite): re-align drifted tests with current code (CI-rehab 2/3) 2026-06-03 19:05:43 +05:00
test_admin_ekburg_permits.py test(suite): re-align drifted tests with current code (CI-rehab 2/3) 2026-06-03 19:05:43 +05:00
test_admin_jobs_settings.py fix(admin-jobs): UPSERT в PUT /admin/jobs/settings — не терять изменения (#1223) 2026-06-13 08:36:23 +00:00
test_admin_scrape_freshness.py fix(freshness): output-floor on cycle-SUM over fresh_days window (#1945, #1947) 2026-06-27 12:36:50 +05:00
test_analyze_competitors_status.py perf(objective): request-path consumers dedup inline, not via whole-table view (#1964) 2026-06-28 05:00:47 +05:00
test_analyze_inline_weights.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_analyze_market_price.py fix(analytics): recommend_mix success-boost regression from view 172 (#1955) 2026-06-27 15:49:40 +05:00
test_analyze_osrm_distances.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_analyze_parcel_meta.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_analyze_recent_permits.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_analyze_zoning_regulation.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_chat.py fix(backend): экранировать Excel formula-injection (#1244) + увести chat-чтение с event loop (#1245) 2026-06-13 18:10:21 +05:00
test_concept_recompute.py fix(generative): forward genuine price_source through /recompute (#1965 Stage 2a) 2026-06-28 00:33:59 +05:00
test_custom_pois.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_insights.py feat(insights): manual-entry Insight entity CRUD + §19 audit (#948 part A) 2026-06-08 12:41:39 +05:00
test_locations.py feat(location): district-level Location entity + indices (#948 part B) 2026-06-08 13:28:19 +05:00
test_osrm_per_category.py feat(analyze): per-category OSRM routing (foot vs driving) (#39 A3) 2026-06-27 04:30:25 +05:00
test_own_projects.py feat(site-finder): own-portfolio data source for §25.3 cannibalization (#1169 PR1) 2026-06-08 16:21:53 +05:00
test_parcel_best_layouts.py fix(best-layouts): per-object latest snapshot for supply (#1956) 2026-06-27 23:24:28 +05:00
test_parcel_by_bbox.py fix(analyze): district KeyError 500 in #994 persist + revive by-bbox tests 2026-06-03 18:04:37 +05:00
test_parcel_competitors.py fix(objective): physflat-dedup current-state consumers + honest n_sold window (#1964) 2026-06-28 04:27:43 +05:00
test_parcel_connection_points.py feat(parcels): connection-points endpoint (Forgejo #115 Phase 1 backend) (#190) 2026-05-16 05:58:27 +00:00
test_parcel_snapshot_exclude_dev.py feat(site-finder): snapshot.pdf exclude_dev param — hide competitor by developer name 2026-06-18 15:23:28 +03:00
test_parcel_utility_infrastructure.py feat(site-finder): OSM engineering-networks loader + endpoint (#1746) (#1930) 2026-06-26 20:01:00 +00:00
test_parcels_forecast.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00
test_run_history_and_response_contract.py fix(report): newbuild-consistent district median + obj_class dedup (#1953) 2026-06-27 15:10:49 +05:00