fix(sf-21b): _INLINE_VELOCITY_SQL weighted AVG (P0 follow-up) #291
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#291
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/sf-21b-inline-velocity-weighted"
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?
🔴 P0 follow-up к #21 (PR #290)
backend/app/services/site_finder/best_layouts.py:121-122(_INLINE_VELOCITY_SQL) использовал тот же broken unweighted AVG pattern напрямую наobjective_corpus_room_month— тот же class bug что и вmv_layout_velocity.Без этого fix — даже после merge PR #290 (mv fix) inline-path (best_layouts.py compute_velocity) всё равно возвращает broken numbers (например studio = 11 м² вместо 28 м²).
Changes
backend/app/services/site_finder/best_layouts.py,_INLINE_VELOCITY_SQL:COALESCE(..., 0)чтобы при absence-data не сломать downstream Python (раньше при NULL Python мог crash на.toFixed()или Decimal arithmetic).Verify after deploy
https://gendsgn.ru/site-finder?cad=66:41:0204016:10→ «Рассчитать» в BestLayouts → studio ~28 м² (не 12), 3-к ~81 м² (не 22).Related: P0 #21b · parent fix PR #290 (SF#21 mv) · epic #271
Merged via deep-code-reviewer — verdict APPROVE.
Что проверено:
SUM(value * count) / NULLIF(SUM(count), 0)корректна, идентична паттерну PR #290.::numeric(N, M)применяется к column expression, не к bind param — psycopg v3 safe (не CAST trap).:cad_quarter,:window_interval,:competitor_obj_ids) сохранены — no injection vector._INLINE_VELOCITY_SQLиспользуется только вcompute_velocity, schema колонок неизменна — downstream callers safe.Sequence: PR #290 (MV fix,
data/sql/100_*.sql) + этот PR #291 (inline path) активируются вместе → consistent UI.Post-deploy verify:
https://gendsgn.ru/site-finder?cad=66:41:0204016:10→ BestLayouts → studio ~28 м² (не 12), 3-к ~81 м² (не 22).Note: existing assertions в
test_best_layouts.pyнаavg_area_m2/avg_price_per_m2_rubмогут expect старые (broken) numbers — flag для апдейта если CI красный.Follow-up:
code/patterns/Pattern_Weighted_Aggregates.md(TBD per vault noteBug_MvLayoutVelocity_UnweightedAvg_May17).