lekss361
|
d7fbaa0528
|
feat(velocity): per-room-bucket breakdown in VelocityResult (#163)
* fix(velocity): :window_interval::interval cast syntax — same bug as PR #152
SQLAlchemy text() parser confuses ':window_interval' (named param) followed
by '::interval' (cast operator) — exactly как было в PR #152 с :weights::jsonb.
Result: psycopg видит literal ':window_interval' в SQL → syntax error →
exception caught by velocity catch → return None → UI shows null.
## Fix
':window_interval::interval' → 'CAST(:window_interval AS interval)' (2 мест:
sales_rows query + _get_ekb_median percentile).
Pre-push code-reviewer должен был catch — добавим в feedback что для каждого
text() SQL grep ':[a-z]*::' before push.
Refs: PR #158 deploy verify, e2e velocity = null root cause
* feat(velocity): add per-room-bucket breakdown to VelocityResult
Add third SQL query (bucket_rows) aggregating deals_total_count by
room_bucket ('студия','1','2','3','4+') across mapped competitors.
New fields:
- VelocityResult.by_room_bucket: aggregate {units, sqm, complexes_count}
- sample_competitors[].by_room_bucket: {bucket: units}
Bucket query wrapped в SAVEPOINT — failure degrades gracefully к empty
dict без abort outer tx.
CAST(:window_interval AS interval) pattern per PR #160 lesson.
Test coverage: 3 new tests (aggregation, empty fallback, sample entries).
Closes part of #161
---------
Co-authored-by: lekss361 <claudestars@proton.me>
|
2026-05-15 10:09:03 +03:00 |
|
lekss361
|
8fa1d005fd
|
feat(velocity): migrate D2 sales source → objective_corpus_room_month (#158)
* feat(velocity): migrate D2 sales source from stale sale_graph to objective_corpus_room_month
Closes #156
* fix(velocity): cross-stack contract + NULL safety per pre-push review
3 pre-push code-reviewer findings fixed:
1. TS union extended ('objective'|'sale_graph'|'rosreestr_fallback')
+ UI conditions handle both objective и sale_graph как valid sources.
2. COALESCE(deals_total_vol_m2, deals_total_count * 45.0) — NULL safety
for DKP-only rows (vol_m2 nullable, count > 0).
3. room_bucket parking filter — verified false positive (все 5 buckets
apartments: студия/1/2/3/4+).
Refs: PR #157 pre-push code-reviewer
* fix(types): add 'objective' to velocity_source union (cherry-pick miss)
Cherry-pick от закрытого PR #157 потерял этот файл. Frontend type-check fails
с 'no overlap' error. Restoring.
Refs: PR #158 frontend CI failure
---------
Co-authored-by: lekss361 <claudestars@proton.me>
|
2026-05-15 09:34:00 +03:00 |
|
lekss361
|
e93bb6121e
|
feat(site-finder): D2 velocity-score from domrf_kn_sale_graph (#34 sub-PR 1/2) (#146)
compute_velocity service queries competitor sales в радиусе 3км:
- ST_MakePoint(longitude, latitude) — domrf_kn_objects не имеет geom column
- JOIN domrf_kn_sale_graph за 6 мес (area_sq primary, realised*45 fallback)
- Normalize vs ЕКБ-wide median → velocity_score 0..1
- confidence: high/medium/low (competitors_count + months_observed)
- Top 5 sample competitors для UI
Integration: analyze_parcel.response['velocity'] top-level field.
Schema corrections vs spec:
- obj_name → comm_name
- region_code → region_cd
- contracted (INT) → area_sq (м²)
Tests: 102/102 pass.
Vault: Module_Velocity_Service.md NEW.
Closes #144 (sub-PR 2 frontend закроет #34)
Co-authored-by: lekss361 <claudestars@proton.me>
|
2026-05-15 01:24:53 +03:00 |
|