change calculation to strictly days

This commit is contained in:
2026-01-25 14:30:02 -05:00
parent b559d5660d
commit 2112af7794
2 changed files with 10 additions and 6 deletions

4
.gitignore vendored
View File

@@ -2,3 +2,7 @@ utils/__pycache__/__init__.cpython-313.pyc
utils/__pycache__/geocode.cpython-313.pyc
utils/__pycache__/weather.cpython-313.pyc
__pycache__/config.cpython-313.pyc
__pycache__/config.cpython-312.pyc
utils/__pycache__/geocode.cpython-312.pyc
utils/__pycache__/weather.cpython-312.pyc
utils/__pycache__/__init__.cpython-312.pyc

View File

@@ -10,21 +10,21 @@ async def get_today_snowfall_async(lat, lon):
tz_name = tf.timezone_at(lat=lat, lng=lon) or "UTC"
async with httpx.AsyncClient(timeout=5) as client:
params = {"latitude": lat, "longitude": lon, "hourly": "snowfall", "timezone": tz_name}
params = {"latitude": lat, "longitude": lon, "daily": "snowfall_sum", "timezone": tz_name}
r = await client.get(OPEN_METEO_URL, params=params)
r.raise_for_status()
data = r.json()
hourly = data.get("hourly", {})
times = hourly.get("time", [])
snow_values = hourly.get("snowfall", [])
daily = data.get("daily", {})
days = daily.get("time", [])
snow_values = daily.get("snowfall_sum", [])
today_str = datetime.now(pytz.timezone(tz_name)).date().isoformat()
snowfall_cm = 0.0
snowing_now = False
for t, s in zip(times, snow_values):
if t.startswith(today_str):
for d, s in zip(days, snow_values):
if d.startswith(today_str):
snowfall_cm += s
if s > 0:
snowing_now = True