Fix data fetch

This commit is contained in:
Urtzi Alfaro
2025-07-27 19:30:42 +02:00
parent 280d356a51
commit 4684235111
5 changed files with 18 additions and 68 deletions

View File

@@ -28,7 +28,7 @@ router = APIRouter(tags=["traffic"])
traffic_service = TrafficService()
logger = structlog.get_logger()
@router.get("/tenants/{tenant_id}/current", response_model=TrafficDataResponse)
@router.get("/tenants/{tenant_id}/traffic/current", response_model=TrafficDataResponse)
async def get_current_traffic(
latitude: float = Query(..., description="Latitude"),
longitude: float = Query(..., description="Longitude"),
@@ -71,7 +71,7 @@ async def get_current_traffic(
logger.error("Traffic API traceback", traceback=traceback.format_exc())
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
@router.get("/tenants/{tenant_id}/historical", response_model=List[TrafficDataResponse])
@router.get("/tenants/{tenant_id}/traffic/historical", response_model=List[TrafficDataResponse])
async def get_historical_traffic(
latitude: float = Query(..., description="Latitude"),
longitude: float = Query(..., description="Longitude"),
@@ -118,7 +118,7 @@ async def get_historical_traffic(
logger.error("Unexpected error in historical traffic API", error=str(e))
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
@router.post("/tenants/{tenant_id}/store")
@router.post("/tenants/{tenant_id}/traffic/store")
async def store_traffic_data(
latitude: float = Query(..., description="Latitude"),
longitude: float = Query(..., description="Longitude"),

View File

@@ -23,7 +23,7 @@ from shared.auth.decorators import (
router = APIRouter(tags=["weather"])
logger = structlog.get_logger()
@router.get("/tenants/{tenant_id}/current", response_model=WeatherDataResponse)
@router.get("/tenants/{tenant_id}/wetaher/current", response_model=WeatherDataResponse)
async def get_current_weather(
latitude: float = Query(..., description="Latitude"),
longitude: float = Query(..., description="Longitude"),
@@ -65,7 +65,7 @@ async def get_current_weather(
logger.error("Failed to get current weather", error=str(e))
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
@router.get("/tenants/{tenant_id}/forecast", response_model=List[WeatherForecastResponse])
@router.get("/tenants/{tenant_id}/weather/forecast", response_model=List[WeatherForecastResponse])
async def get_weather_forecast(
latitude: float = Query(..., description="Latitude"),
longitude: float = Query(..., description="Longitude"),
@@ -109,7 +109,7 @@ async def get_weather_forecast(
logger.error("Failed to get weather forecast", error=str(e))
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
@router.get("/tenants/{tenant_id}/history", response_model=List[WeatherDataResponse])
@router.get("/tenants/{tenant_id}/weather/history", response_model=List[WeatherDataResponse])
async def get_weather_history(
start_date: date = Query(..., description="Start date"),
end_date: date = Query(..., description="End date"),
@@ -125,7 +125,7 @@ async def get_weather_history(
tenant_id=tenant_id)
weather_service = WeatherService()
history = await weather_service.get_weather_history(
history = await weather_service.get_historical_weather(
latitude, longitude, start_date, end_date
)
@@ -135,7 +135,7 @@ async def get_weather_history(
logger.error("Failed to get weather history", error=str(e))
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
@router.post("/tenants/{tenant_id}/sync")
@router.post("/tenants/{tenant_id}weather/sync")
async def sync_weather_data(
background_tasks: BackgroundTasks,
force: bool = Query(False, description="Force sync even if recently synced"),