Start fixing forecast service 15
This commit is contained in:
@@ -231,38 +231,37 @@ class DataServiceClient(BaseServiceClient):
|
||||
async def get_weather_forecast(
|
||||
self,
|
||||
tenant_id: str,
|
||||
days: str,
|
||||
days: int = 1,
|
||||
latitude: Optional[float] = None,
|
||||
longitude: Optional[float] = None
|
||||
) -> Optional[List[Dict[str, Any]]]:
|
||||
"""
|
||||
Get weather data for a date range and location
|
||||
Uses POST request as per original implementation
|
||||
Get weather forecast for location
|
||||
FIXED: Uses GET request with query parameters as expected by the weather API
|
||||
"""
|
||||
# Prepare request payload with proper date handling
|
||||
payload = {
|
||||
"latitude": latitude or 40.4168, # Default Madrid coordinates
|
||||
"longitude": longitude or -3.7038,
|
||||
"days": days # Already in ISO format from calling code
|
||||
"days": days
|
||||
}
|
||||
|
||||
logger.info(f"Weather request payload: {payload}", tenant_id=tenant_id)
|
||||
logger.info(f"Weather forecast request params: {payload}", tenant_id=tenant_id)
|
||||
|
||||
# Use POST request with extended timeout
|
||||
result = await self._make_request(
|
||||
"POST",
|
||||
"weather/forecast",
|
||||
tenant_id=tenant_id,
|
||||
data=payload,
|
||||
timeout=2000.0 # Match original timeout
|
||||
timeout=200.0
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info(f"Successfully fetched {len(result)} weather forecast for {days}")
|
||||
logger.info(f"Successfully fetched weather forecast for {days} days")
|
||||
return result
|
||||
else:
|
||||
logger.error("Failed to fetch weather data")
|
||||
logger.error("Failed to fetch weather forecast")
|
||||
return []
|
||||
|
||||
|
||||
# ================================================================
|
||||
# TRAFFIC DATA
|
||||
|
||||
Reference in New Issue
Block a user