Sprint 11: Freunde & Chat + Phosphor-Icon-Vollmigration

- Freundschaften (pending/accepted), Nutzersuche, Anfragen per Push
- Direktnachrichten mit Polling, iMessage-Stil, Deep-Links aus Push
- Alle Seiten (map, places, diary, health, dog-profile, sitting, knigge,
  forum, wiki, walks) vollständig auf Phosphor-Icons migriert
- Wikidata-Rassen-Scraper (~833 neue Rassen, lokal gespiegelte Fotos)
- TheDogAPI lokal gespiegelt (169 Rassen + Fotos)
- Quiz-Result-Cards horizontal (korrekte Bildproportionen)
- SW by-v89
This commit is contained in:
rene 2026-04-15 21:33:53 +02:00
parent 96bd57f0ad
commit 097295c628
44 changed files with 9980 additions and 300 deletions

71
backend/weather.py Normal file
View file

@ -0,0 +1,71 @@
"""
BAN YARO Wetter-Zusammenfassung via Open-Meteo
Prüft mehrere deutsche Städte und liefert max. Temperatur und Gewitterwarnung.
"""
import logging
import httpx
logger = logging.getLogger(__name__)
# Wichtige deutsche Städte als Stichprobe
CITIES = [
{"name": "Berlin", "lat": 52.52, "lon": 13.41},
{"name": "München", "lat": 48.14, "lon": 11.58},
{"name": "Hamburg", "lat": 53.55, "lon": 10.00},
{"name": "Frankfurt", "lat": 50.11, "lon": 8.68},
{"name": "Köln", "lat": 50.94, "lon": 6.96},
]
# WMO-Wettercodes 9599 = Gewitter
THUNDERSTORM_CODES = {95, 96, 99}
async def get_weather_summary() -> dict:
"""
Holt Tagesprognose für mehrere deutsche Städte von Open-Meteo.
Gibt zurück: {"max_temp_c": float, "thunderstorm": bool}
"""
max_temp = -999.0
thunderstorm = False
async with httpx.AsyncClient(timeout=10.0) as client:
for city in CITIES:
url = (
"https://api.open-meteo.com/v1/forecast"
f"?latitude={city['lat']}&longitude={city['lon']}"
"&daily=temperature_2m_max,precipitation_probability_max,weathercode"
"&timezone=Europe%2FBerlin&forecast_days=1"
)
try:
resp = await client.get(url)
resp.raise_for_status()
data = resp.json()
daily = data.get("daily", {})
temps = daily.get("temperature_2m_max", [None])
precip_probs = daily.get("precipitation_probability_max", [None])
weathercodes = daily.get("weathercode", [None])
temp = temps[0] if temps else None
precip_prob = precip_probs[0] if precip_probs else None
weathercode = weathercodes[0] if weathercodes else None
if temp is not None and temp > max_temp:
max_temp = temp
if (
precip_prob is not None and precip_prob > 50
and weathercode is not None and int(weathercode) in THUNDERSTORM_CODES
):
thunderstorm = True
logger.info(f"Gewitter erkannt: {city['name']} (Code {weathercode}, {precip_prob}% Niederschlag)")
except Exception as e:
logger.warning(f"Wetter-Abruf für {city['name']} fehlgeschlagen: {e}")
if max_temp == -999.0:
max_temp = 0.0
logger.info(f"Wetter-Zusammenfassung: max_temp={max_temp}°C, thunderstorm={thunderstorm}")
return {"max_temp_c": max_temp, "thunderstorm": thunderstorm}