Uprava prace s DB, refaktoring
This commit is contained in:
Vendored
+1
-2
@@ -1,5 +1,4 @@
|
||||
from typing import List, Tuple, Dict
|
||||
|
||||
from typing import List, Dict
|
||||
import aiohttp
|
||||
|
||||
|
||||
|
||||
Vendored
+4
-3
@@ -37,7 +37,7 @@ class Weather:
|
||||
query_string = urllib.parse.urlencode(params)
|
||||
return f"{url}{query_string}"
|
||||
|
||||
@cached(ttl=6*3600)
|
||||
@cached(ttl=6 * 3600)
|
||||
async def download_weather_for_day(self, date: datetime.date, gps: Tuple[float, float]):
|
||||
url = self.get_weather_info_url(start_date=date, end_date=date, gps=gps)
|
||||
|
||||
@@ -46,7 +46,8 @@ class Weather:
|
||||
resp.raise_for_status()
|
||||
return await resp.json()
|
||||
|
||||
async def get_weather_for_hour(self, date_time: datetime.datetime, gps: Tuple[float, float]) -> Dict[str, float|str]:
|
||||
async def get_weather_for_hour(
|
||||
self, date_time: datetime.datetime, gps: Tuple[float, float]) -> Dict[str, float | str]:
|
||||
data = await self.download_weather_for_day(date_time.date(), gps)
|
||||
|
||||
# TODO: kontrola timezone!
|
||||
@@ -55,4 +56,4 @@ class Weather:
|
||||
result_data = {metric: data['hourly'][metric][idx] for metric in self.METRICS}
|
||||
result_data['datetime'] = datetime.datetime.strptime(data['hourly']['time'][idx], "%Y-%m-%dT%H:%M")
|
||||
|
||||
return result_data
|
||||
return result_data
|
||||
|
||||
Reference in New Issue
Block a user