fix(sf-01): time_window honest velocity — inline SQL с реальным фильтром report_month #275
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#275
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/sf-01-velocity-time-window"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
SF FixList #1 — fix главного «обмана» в Анализе планировок.
Раньше
_VELOCITY_DIVISORSделил агрегатыmv_layout_velocity(всегда 24 мес) на 4/12 дляtime_window=quarter/year, не меняя реальное окно данных → mix/цена/число ЖК идентичные при переключении.Изменения
_VELOCITY_DIVISORSи_VELOCITY_BY_ROOM_SQL(черезmv_layout_velocity)_TIME_WINDOW_PARAMS:last_month→ 1 месlast_quarter→ 3 месlast_year→ 12 мес_INLINE_VELOCITY_SQLчитаетobjective_corpus_room_monthнапрямую:velocity_per_month = deals_window / months_in_windowTest plan
test_best_layouts.pyextended + new tests)/best-layouts?time_window=last_quartervs?time_window=last_year→ разный mix (не только divisor)Files
backend/app/services/site_finder/best_layouts.py— main fixbackend/tests/services/site_finder/test_best_layouts.py— new, 11 testsbackend/tests/api/v1/test_parcel_best_layouts.py— mock updatedfixes/Fix_SF_TimeWindow_Honest_May17.mdRelated: epic #271 item #1 (Wave 1)
Deep Code Review — verdict ✅ APPROVE
Head SHA:
c7016365(mergeable: true — rebase уже выполнен автором в merge-commit 12:15 MSK).Pre-check на конфликт с PR #274
Merge-commit
c7016365корректно резолвит конфликт вbest_layouts.py:deals_window / months_in_window) сохранён ✅is_oversoldflag +sold_pct = min(round(raw, 1), 100.0)clamp (PR #274) сохранён в строках 388-396 ✅Оба фикса сосуществуют корректно —
sold_pct_raw = deals_window / supply_count * 100.0использует новыйdeals_window(не sum_deals 24 мес), что делает clamp ещё точнее.Что проверено
SQL / DB schema:
_INLINE_VELOCITY_SQLиспользует существующие колонкиobjective_corpus_room_month:deals_total_count,deals_total_avg_area_m2,deals_total_avg_price_thousand_rub_per_m2,report_month,project_name,room_bucket— проверено через MCP.objective_complex_mapping.objective_complex_name = crm.project_name— корректный после PR #273 seed.CAST(:window_interval AS interval)— psycopg v3 / SQLAlchemy 2.0 safe (не::interval).'студия' → 'studio'normalization в обоих CASE (SELECT + GROUP BY) — consistent.Performance (EXPLAIN на проде через MCP):
Total cost ~300 — приемлемо для on-request без MV. Регрессии нет.
Correctness:
_TIME_WINDOW_PARAMS.get(request.time_window, ("3 months", 3.0))— defensive fallback ✅months_in_window > 0гарантирован конструкцией dict → нет div-by-zero ✅time_window: Literal["last_month","last_quarter","last_year"]вschemas/parcel.py:235— frontend type-safe ✅Tests: 11 unit-тестов в новом
test_best_layouts.py. Ключевой acceptance —test_different_time_windows_produce_different_velocity(last_month > last_quarter > last_year при одинаковом deals_window).Vault:
fixes/Fix_SF_TimeWindow_Honest_May17.mdсоздана, корректно фиксирует чтоmv_layout_velocityоставлена (используется вadmin_etl.pyREFRESH +layout_velocity_refresh.py).🟢 Low / nits (не блокирующее, future PR)
best_layouts.py:394— комментарий внутри clamp-блока («сделки за 24 мес») устарел: теперьdeals_windowфильтрован по окну. Унаследовано от PR #274.api/v1/parcels.py:2381(вне scope) — docstringReads from mv_layout_velocityустарел для/best-layouts.Verdict
✅ APPROVE — оба SF-01 и SF-05 фикса работают вместе, performance ОК, schema совпадает, tests покрывают acceptance criteria. На следующей итерации polling — можно мержить.
Re-merge after rebase via deep-code-reviewer — все blockers закрыты.
Previous APPROVE: #275 (comment)
Sanity check pre-merge:
c7016365158a0dbceee3aef6c0750e71f427d042— стабильный с момента previous review (no new pushes)mergeable: true,state: open,draft: falseMerge commit:
15e75c20dc8f21462f8b49974d5fcb5a27a6a7efPost-deploy smoke checks (manual):
GET /best-layouts?time_window=last_quartervs?time_window=last_year→ mix/цена/число ЖК должны отличаться (не просто divisor)objective_corpus_room_monthfilter — Index Scan, cost ~300sold_pctclamp в [0,1] +is_oversoldфлаг работает на oversold кейсах