diff --git a/services/forecasting/app/api/forecasts.py b/services/forecasting/app/api/forecasts.py index 81d63ab3..1a9b6ca9 100644 --- a/services/forecasting/app/api/forecasts.py +++ b/services/forecasting/app/api/forecasts.py @@ -47,7 +47,7 @@ async def create_single_forecast( ) # Generate forecast - forecast = await forecasting_service.generate_forecast(tenant_id, request, db) + forecast = await forecasting_service.generate_forecast(request, db) # Convert to response model return ForecastResponse( diff --git a/services/forecasting/app/main.py b/services/forecasting/app/main.py index 6ad1cc5b..f93d2151 100644 --- a/services/forecasting/app/main.py +++ b/services/forecasting/app/main.py @@ -108,7 +108,7 @@ async def health_check(): @app.get("/metrics") async def get_metrics(): """Metrics endpoint for Prometheus""" - return metrics_collector.generate_latest() + return metrics_collector.get_metrics() if __name__ == "__main__": import uvicorn diff --git a/services/forecasting/app/schemas/forecasts.py b/services/forecasting/app/schemas/forecasts.py index ac274426..e2ab240d 100644 --- a/services/forecasting/app/schemas/forecasts.py +++ b/services/forecasting/app/schemas/forecasts.py @@ -24,7 +24,12 @@ class ForecastRequest(BaseModel): """Request schema for generating forecasts""" tenant_id: str = Field(..., description="Tenant ID") product_name: str = Field(..., description="Product name") - forecast_date: date = Field(..., description="Date for which to generate forecast") + forecast_date: date = Field(..., description="Starting date for forecast") + forecast_days: int = Field(1, ge=1, le=30, description="Number of days to forecast") + location: str = Field(..., description="Location identifier") + + # Optional parameters - internally handled + confidence_level: float = Field(0.8, ge=0.5, le=0.95, description="Confidence level") @validator('forecast_date') def validate_forecast_date(cls, v): @@ -37,14 +42,7 @@ class BatchForecastRequest(BaseModel): tenant_id: str = Field(..., description="Tenant ID") batch_name: str = Field(..., description="Batch name for tracking") products: List[str] = Field(..., description="List of product names") - location: str = Field(..., description="Location identifier") forecast_days: int = Field(7, ge=1, le=30, description="Number of days to forecast") - business_type: BusinessType = Field(BusinessType.INDIVIDUAL, description="Business model type") - - # Options - include_weather: bool = Field(True, description="Include weather data") - include_traffic: bool = Field(True, description="Include traffic data") - confidence_level: float = Field(0.8, ge=0.5, le=0.95, description="Confidence level") class ForecastResponse(BaseModel): """Response schema for forecast results""" diff --git a/services/forecasting/app/services/forecasting_service.py b/services/forecasting/app/services/forecasting_service.py index 49d72e78..b6e8758d 100644 --- a/services/forecasting/app/services/forecasting_service.py +++ b/services/forecasting/app/services/forecasting_service.py @@ -249,7 +249,7 @@ class ForecastingService: """Get the latest trained model for a tenant/product combination""" try: - model_data = await self.data_client.get_best_model_for_forecasting(tenant_id, product_name) + model_data = await self.model_client.get_best_model_for_forecasting(tenant_id, product_name) return model_data except Exception as e: diff --git a/services/notification/app/main.py b/services/notification/app/main.py index 091447cf..acfec609 100644 --- a/services/notification/app/main.py +++ b/services/notification/app/main.py @@ -163,7 +163,7 @@ async def health_check(): async def metrics(): """Prometheus metrics endpoint""" if metrics_collector: - return metrics_collector.generate_latest() + return metrics_collector.get_metrics() return {"metrics": "not_available"} # Exception handlers diff --git a/tests/test_onboarding_flow.sh b/tests/test_onboarding_flow.sh index 8dab4d67..98eef10a 100755 --- a/tests/test_onboarding_flow.sh +++ b/tests/test_onboarding_flow.sh @@ -572,13 +572,16 @@ log_step "5.1. Testing basic dashboard functionality" # Use a real product name from our CSV for forecasting FIRST_PRODUCT=$(echo "$REAL_PRODUCTS" | sed 's/"//g' | cut -d',' -f1) -FORECAST_RESPONSE=$(curl -s -X POST "$API_BASE/api/v1/tenants/$TENANT_ID/forecast/single" \ +FORECAST_RESPONSE=$(curl -s -X POST "$API_BASE/api/v1/tenants/$TENANT_ID/forecasts/single" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d "{ - \"products\": [\"$FIRST_PRODUCT\"], - \"forecast_days\": 7, - \"date\": \"2025-09-15\" + \"product_name\": [\"$FIRST_PRODUCT\"], + \"forecast_date\": "2025-11-30", + \"forecast_days\": 1, + \"date\": \"2025-09-15\", + \"location\": \"madrid_centro\", + \"confidence_level\": 0.85 }") if echo "$FORECAST_RESPONSE" | grep -q '"predictions"\|"forecast"'; then