map debug + coord backfill, remove email channel, countdown label
- Surface "X/Y passende Wohnungen mit Koordinaten" on the Karte view +
admin-only "Koordinaten nachladen" button (POST /actions/backfill-coords)
that geocodes missing flats via Google Maps directly from the web container
- Add googlemaps dep + GMAPS_API_KEY env to web service
- Light console.log in map.js ("rendering N/M markers", "building Leaflet…")
so the browser DevTools shows what's happening
- Drop e-mail channel from notifications UI, notify dispatcher, and _alert_status;
coerce legacy 'email' channel rows back to 'ui' on save
- Countdown said "Aktualisierung läuft…" next to "nächste Aktualisierung" →
shortened to "aktualisiere…"
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
51b6b02b24
commit
0c58242ce7
11 changed files with 149 additions and 58 deletions
46
web/geocode.py
Normal file
46
web/geocode.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""Thin Google-Maps geocoding wrapper used only for the admin coord backfill.
|
||||
|
||||
Runtime geocoding during scraping happens in the alert service. This module
|
||||
exists so the web service can lazy-fix flats that were scraped before the
|
||||
lat/lng migration (or where the alert run skipped geocoding).
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from settings import GMAPS_API_KEY
|
||||
|
||||
logger = logging.getLogger("web.geocode")
|
||||
|
||||
_client = None
|
||||
|
||||
|
||||
def _get_client():
|
||||
global _client
|
||||
if _client is not None:
|
||||
return _client
|
||||
if not GMAPS_API_KEY:
|
||||
return None
|
||||
try:
|
||||
import googlemaps
|
||||
_client = googlemaps.Client(key=GMAPS_API_KEY)
|
||||
return _client
|
||||
except Exception as e:
|
||||
logger.warning("googlemaps client init failed: %s", e)
|
||||
return None
|
||||
|
||||
|
||||
def geocode(address: str) -> Optional[tuple[float, float]]:
|
||||
if not address:
|
||||
return None
|
||||
gm = _get_client()
|
||||
if gm is None:
|
||||
return None
|
||||
try:
|
||||
res = gm.geocode(f"{address}, Berlin, Germany")
|
||||
if not res:
|
||||
return None
|
||||
loc = res[0]["geometry"]["location"]
|
||||
return float(loc["lat"]), float(loc["lng"])
|
||||
except Exception as e:
|
||||
logger.warning("geocode failed for %r: %s", address, e)
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue