Add backend/app/services/forecasting/sales_series.py — deterministic monthly sold-units (+area+avg price) time series per SegmentSpec, the Y-axis foundation for the §9.6 key-rate regression. Two sources with distinct authority: objective_corpus_room_month (class/district aggregates, full ДДУ+ДКП, count- weighted price ×1000 тыс→₽) and objective_lots (room×area×price segmentation, GROUP BY date_trunc registration_date; survivorship caveat documented). Pure DB-free helpers price_bucket_of / room_area_bucket_of / log_diff / fill_month_grid, unit-tested. In-SQL CASE bucketing shares the same threshold constants as the helpers (bound params) → no Python↔SQL drift. Months with no sales → units=0 (real zero), area/price → None. Graceful empty/thin → low confidence, zero-filled grid. Mirrors macro_series.py (PR2). room_bucket semantics are source-specific (documented on SegmentSpec). 62 tests, ruff clean. |
||
|---|---|---|
| .. | ||
| api | ||
| integration | ||
| scrapers | ||
| services | ||
| smoke | ||
| sql | ||
| workers | ||
| __init__.py | ||
| test_admin_weight_profiles.py | ||
| test_concepts_stub.py | ||
| test_gate_verdict.py | ||
| test_health.py | ||
| test_layout_signature.py | ||
| test_layout_tz_pdf.py | ||
| test_nspd_client.py | ||
| test_nspd_sync.py | ||
| test_ping.py | ||
| test_poi_score.py | ||
| test_quarter_dump_lookup.py | ||
| test_rbac.py | ||
| test_sentry_init.py | ||
| test_velocity.py | ||
| test_weight_profiles.py | ||