This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import datetime
|
||||
from os import environ
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from gallery.sketch.source import ApiSource
|
||||
from gallery.sketch.weather.api import WeatherApi
|
||||
from gallery.sketch.weather.model import Location, WeatherResponse
|
||||
@@ -46,9 +44,7 @@ class GismeteoApi(WeatherApi):
|
||||
async def get_day(self, location_id: str, date: datetime.date) -> WeatherResponse:
|
||||
max_date = datetime.date.today() + datetime.timedelta(days=9)
|
||||
if date > max_date:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST, detail={"max_date": max_date.strftime("%Y-%m-%d")}
|
||||
)
|
||||
raise ValueError(f"Invalid date: {date}, max: {max_date}")
|
||||
data = await self.source.request(f"weather-{location_id}/{format_date(date)}")
|
||||
context = ForecastData(date, "day", data, 8)
|
||||
return self.forecast_parser.parse(context)
|
||||
|
||||
Reference in New Issue
Block a user