banyaro/backend
rene 297bd22f96 Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114
NEUE BACKEND-MODULE:

math_utils.py
- haversine_km(lat1, lon1, lat2, lon2) — Distanz in km
- haversine_m(...) — Convenience-Wrapper in Metern
- bbox_deg_from_km(lat, radius_km) — Bounding-Box-Approximation
  für SQL-Vorfilter (statt Haversine im Python-Loop)

config.py
- DB_PATH, MEDIA_DIR, BREEDER_DOCS_DIR, SCANINPUT_DIR
- API_TIMEOUT_SHORT (5s) / DEFAULT (10s) / LONG (30s)
- HTTP_USER_AGENT, HTTP_HEADERS

errors.py
- not_found(msg), forbidden(msg), bad_request(msg), unauthorized(msg)
- conflict(msg), too_many_requests(msg, retry_after), service_unavailable(msg)
- require_or_404(row, msg) — Convenience-Helper

UI.JS ERWEITERUNGEN:

UI.time erweitert:
- formatDate(d)     → "15.03.2026"
- formatDateTime(d) → "15.03.2026, 14:30"
- weekday(d)        → "Di"
- parseISO(str)     → {year, month, day}

UI.text (neu):
- truncate(str, maxLen, ellipsis='…')
- slug(str) — URL-Slug aus String (mit DE-Umlauten)

UI.money (neu):
- format(value) → "12,34 €" (de-DE, EUR)
- formatWithSuffix(value, '/Jahr')

HAVERSINE-MIGRATION (13 Backend-Routen):
alerts.py, services.py, places.py, events.py, diary.py, playdate.py,
lost.py, poison.py, adoption.py, gassi_zeiten.py, sitting.py, routen.py,
walks.py

- Alle lokalen def _haversine/haversine_km entfernt
- Aufrufe ersetzt durch haversine_km/haversine_m je nach Einheit
- from math_utils import haversine_km|haversine_m in jeder Datei

Tests 19/19 grün.

Hinweis: Migrationen für MEDIA_DIR (19 Stellen), API-Timeouts (12),
Date-Formatter im Frontend (24) und UI.text.truncate (5) sind als
Folge-Sprints möglich. Helper sind verfügbar.
2026-05-27 11:19:06 +02:00
..
routes Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114 2026-05-27 11:19:06 +02:00
scraper Fix: VDH-Fallback-Events aktualisiert — Frankfurt Mai entfernt (vergangen), 7 korrekte Termine 2026 2026-05-08 13:52:37 +02:00
scripts Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
static Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114 2026-05-27 11:19:06 +02:00
auth.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
cache.py Perf: 9 Performance-Fixes — SW by-v1072 2026-05-26 06:30:36 +02:00
config.py Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114 2026-05-27 11:19:06 +02:00
content_filter.py Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
database.py Big Sweep: Security + Race-Conditions + Tests + DSGVO + A11y, SW by-v1095 2026-05-26 20:12:01 +02:00
entrypoint.sh Revert Dockerfile USER appuser (Synology DSM ACL inkompatibel) 2026-04-23 18:52:51 +02:00
errors.py Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114 2026-05-27 11:19:06 +02:00
generate_thumbs.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
ki.py Fix: KI health_summary Kontextfenster (max 5 Einträge), Cloud-Priority ohne ANTHROPIC_KEY-Check, local-Fallback wrapped (SW by-v798) 2026-05-09 20:08:06 +02:00
mailer.py Fix: Date-Header in ausgehenden Mails (formatdate UTC, Container hat keine lokale TZ) 2026-05-15 12:37:41 +02:00
main.py Fix: /force-update reload-Hänger + Cooldown persistent, SW by-v1106 2026-05-27 08:02:54 +02:00
math_utils.py Bündel 2: Zentrale Helper für DRY-Cleanup, SW by-v1114 2026-05-27 11:19:06 +02:00
media_utils.py Fix: Karte lädt wieder + safe_media_path + Foto-Löschung (SW by-v932) 2026-05-14 11:58:00 +02:00
migrate_media.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
ratelimit.py Security + E-Mail-HTML + Quartalsbericht + Registrierungspflicht 2026-05-01 08:20:53 +02:00
requirements.txt Chore: Sprint32-36 Zwischenstand — alle Änderungen aus dieser Session committen 2026-05-03 11:09:39 +02:00
scheduler.py Bündel A-D: Race-Fixes, JWT-Cleanup, Storage-Watchdog, HTTPException, SW by-v1112 2026-05-27 09:41:56 +02:00
timeutils.py Teil 3: Terminvorschläge + KI-Limit-Bypass für Admins/Mods — SW by-v435, APP_VER 414 2026-04-26 17:08:18 +02:00
username_blocklist.py Session 2026-04-20: Medien-Konvertierung, Umami Analytics, Username/Privacy 2026-04-20 18:36:58 +02:00
weather.py Fix: Asphalttemperatur-Formel temperaturabhängig (t_factor 0..1 zwischen 5-30°C), nicht mehr temperaturblind 2026-05-16 13:53:05 +02:00
welfare_check.py Feature: Tierschutz-Check, KI-Züchter-Features, Export, SEO-Update 2026-04-28 19:49:54 +02:00