feat(parcels): §22 forecast in analyze endpoint — horizon+enqueue+GET (Step 3b-ii) #1069
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#1069
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/forecast-endpoint-horizon-enqueue"
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?
What — Step 3b-ii (FINAL): §22 forecast reaches the analyze API
Completes EPIC 17 backend wiring. The 3b-i Celery task is live-validated (worker computes §22 in ~45s → persists schema_version="1.0" run). This wires it to the endpoint.
horizonquery param onPOST /{cad}/analyze— {6,12,18} (#995), default 12; invalid → 422 before any DB/compute (pre-flight guard).forecast_site_finder_report.delay(cad, horizon, created_by)after the existing persist — lazy import (no api↔workers cycle), try/except: Celery/Redis down →forecast.status="unavailable", analyze still 200 (never blocks/500s). Adds additiveresult_payload["forecast"] = {status: pending|unavailable, horizon}.GET /{cad}/forecast(read-only): latestschema_version="1.0"run → 200{status:ready, run_id, created_at, report}(the §22 dict) else 202{status:pending}; graceful on DB error (202, never 500). Mirrors fetch-status RBAC/style.Flow
POST /analyze?horizon=12→ site-analysis returns immediately (forecast.status=pending) + enqueues → worker runs §22 (~45-180s) → persists "1.0" → client pollsGET /{cad}/forecast(202→200 withreport.schema_version="1.0").Quality
risksetc. unchanged); horizon 422 before side-effects (.delaynot called); GET reads "1.0" not "analyze-1.0", degrades to 202 not 500; enqueue arg-order correct; no import cycle; no new auth hole. 96 api tests pass; ruff/psycopg clean.logger.warning(exc_info=True)mitigates — Glitchtip should watch it).Additive only — existing analyze keys unchanged. Refs #995 #992 #961.
Final forecast wiring — §22 reaches the API. - horizon query param on POST /{cad}/analyze ({6,12,18}, default 12; 422 before any DB/compute work otherwise). - best-effort fire-and-forget forecast_site_finder_report.delay(cad, horizon, created_by) after persist (lazy import, no api↔workers cycle); Celery/Redis down → forecast.status='unavailable', analyze still 200 (never blocks/500s). Adds additive result_payload['forecast'] = {status: pending|unavailable, horizon}. - new read-only GET /{cad}/forecast: latest schema_version='1.0' run → 200 {status:ready, run_id, created_at, report} else 202 {status:pending}; graceful on DB error (202, never 500). Mirrors fetch-status RBAC/style. Additive only — existing analyze response keys unchanged. code-review APPROVE (analyze uncrashable + additive; 422 pre-flight; GET reads '1.0' not 'analyze-1.0'). 96 api tests pass; ruff clean. Refs #995 #992 #961.