Fix forecasting service

This commit is contained in:
Urtzi Alfaro
2025-07-21 20:43:17 +02:00
parent 0e7ca10a29
commit 153ae3f154
11 changed files with 107 additions and 534 deletions

View File

@@ -12,7 +12,10 @@ from typing import List, Dict, Any
from datetime import date, datetime, timedelta
from app.core.database import get_db
from app.core.auth import get_current_user_from_headers
from shared.auth.decorators import (
get_current_user_dep,
get_current_tenant_id_dep
)
from app.services.prediction_service import PredictionService
from app.schemas.forecasts import ForecastRequest
@@ -28,12 +31,11 @@ async def get_realtime_prediction(
location: str,
forecast_date: date,
features: Dict[str, Any],
current_user: dict = Depends(get_current_user_from_headers)
tenant_id: str = Depends(get_current_tenant_id_dep)
):
"""Get real-time prediction without storing in database"""
try:
tenant_id = str(current_user.get("tenant_id"))
# Get latest model
from app.services.forecasting_service import ForecastingService
@@ -83,13 +85,12 @@ async def get_quick_prediction(
product_name: str,
location: str = Query(...),
days_ahead: int = Query(1, ge=1, le=7),
current_user: dict = Depends(get_current_user_from_headers)
tenant_id: str = Depends(get_current_tenant_id_dep)
):
"""Get quick prediction for next few days"""
try:
tenant_id = str(current_user.get("tenant_id"))
# Generate predictions for the next N days
predictions = []