|
|
|
@ -9,6 +9,7 @@ from typing import List, Union
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
import aiofiles
|
|
|
|
|
from quart import current_app as app
|
|
|
|
|
|
|
|
|
|
import settings
|
|
|
|
|
from wowlet_backend.utils import httpget
|
|
|
|
@ -93,6 +94,15 @@ class HistoricalPriceTask(WowletTask):
|
|
|
|
|
data filtered by the parameters."""
|
|
|
|
|
from wowlet_backend.factory import cache
|
|
|
|
|
|
|
|
|
|
# redis keys are always strings, convert input parameters
|
|
|
|
|
year = str(year)
|
|
|
|
|
if isinstance(month, int):
|
|
|
|
|
month = str(month)
|
|
|
|
|
|
|
|
|
|
if not year.isnumeric() or (month and not month.isnumeric()):
|
|
|
|
|
app.logger.error(f"get() called with year: {year}, month {month}, not a number")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
blob = await cache.get("historical_fiat")
|
|
|
|
|
blob = json.loads(blob)
|
|
|
|
|
if year not in blob:
|
|
|
|
@ -102,13 +112,13 @@ class HistoricalPriceTask(WowletTask):
|
|
|
|
|
if not month:
|
|
|
|
|
for _m, days in blob[year].items():
|
|
|
|
|
for day, price in days.items():
|
|
|
|
|
rtn[datetime(year, _m, day).strftime('%Y%m%d')] = price
|
|
|
|
|
rtn[datetime(int(year), int(_m), int(day)).strftime('%Y%m%d')] = price
|
|
|
|
|
return rtn
|
|
|
|
|
|
|
|
|
|
if month not in blob[year]:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
for day, price in blob[year][month].items():
|
|
|
|
|
rtn[datetime(year, month, day).strftime('%Y%m%d')] = price
|
|
|
|
|
rtn[datetime(int(year), int(month), int(day)).strftime('%Y%m%d')] = price
|
|
|
|
|
|
|
|
|
|
return rtn
|
|
|
|
|