Kartenfeature: Geoparsing + Leaflet-Karte im Dashboard
- Neues Geoparsing-Modul (spaCy NER + geonamescache/Nominatim)
- article_locations-Tabelle mit Migration
- Pipeline-Integration nach Artikel-Speicherung
- API-Endpunkt GET /incidents/{id}/locations
- Leaflet.js + MarkerCluster im Dashboard-Grid
- Theme-aware Kartenkacheln (CartoDB dark / OSM light)
- Gold-Akzent MarkerCluster, Popup mit Artikelliste
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dieser Commit ist enthalten in:
@@ -271,6 +271,55 @@ async def get_factchecks(
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
|
||||
@router.get("/{incident_id}/locations")
|
||||
async def get_locations(
|
||||
incident_id: int,
|
||||
current_user: dict = Depends(get_current_user),
|
||||
db: aiosqlite.Connection = Depends(db_dependency),
|
||||
):
|
||||
"""Geografische Orte einer Lage abrufen (aggregiert nach Ort)."""
|
||||
tenant_id = current_user.get("tenant_id")
|
||||
await _check_incident_access(db, incident_id, current_user["id"], tenant_id)
|
||||
cursor = await db.execute(
|
||||
"""SELECT al.location_name, al.location_name_normalized, al.country_code,
|
||||
al.latitude, al.longitude, al.confidence,
|
||||
a.id as article_id, a.headline, a.headline_de, a.source, a.source_url
|
||||
FROM article_locations al
|
||||
JOIN articles a ON a.id = al.article_id
|
||||
WHERE al.incident_id = ?
|
||||
ORDER BY al.location_name_normalized, a.collected_at DESC""",
|
||||
(incident_id,),
|
||||
)
|
||||
rows = await cursor.fetchall()
|
||||
|
||||
# Aggregierung nach normalisiertem Ortsnamen + Koordinaten
|
||||
loc_map = {}
|
||||
for row in rows:
|
||||
row = dict(row)
|
||||
key = (row["location_name_normalized"] or row["location_name"], round(row["latitude"], 2), round(row["longitude"], 2))
|
||||
if key not in loc_map:
|
||||
loc_map[key] = {
|
||||
"location_name": row["location_name_normalized"] or row["location_name"],
|
||||
"lat": row["latitude"],
|
||||
"lon": row["longitude"],
|
||||
"country_code": row["country_code"],
|
||||
"confidence": row["confidence"],
|
||||
"article_count": 0,
|
||||
"articles": [],
|
||||
}
|
||||
loc_map[key]["article_count"] += 1
|
||||
# Maximal 10 Artikel pro Ort mitliefern
|
||||
if len(loc_map[key]["articles"]) < 10:
|
||||
loc_map[key]["articles"].append({
|
||||
"id": row["article_id"],
|
||||
"headline": row["headline_de"] or row["headline"],
|
||||
"source": row["source"],
|
||||
"source_url": row["source_url"],
|
||||
})
|
||||
|
||||
return list(loc_map.values())
|
||||
|
||||
|
||||
@router.get("/{incident_id}/refresh-log")
|
||||
async def get_refresh_log(
|
||||
incident_id: int,
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren