diff --git a/backend/database.py b/backend/database.py index 89c141e..01dfc17 100644 --- a/backend/database.py +++ b/backend/database.py @@ -1236,11 +1236,16 @@ def _migrate(conn_factory): CREATE TABLE IF NOT EXISTS ki_health_reports ( id INTEGER PRIMARY KEY AUTOINCREMENT, dog_id INTEGER NOT NULL REFERENCES dogs(id) ON DELETE CASCADE, - user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + user_id INTEGER REFERENCES users(id) ON DELETE CASCADE, bericht TEXT NOT NULL, erstellt_at TEXT NOT NULL DEFAULT (datetime('now')) ) """) + # user_id nachträglich ergänzen falls Tabelle ohne diese Spalte erstellt wurde + try: + conn.execute("ALTER TABLE ki_health_reports ADD COLUMN user_id INTEGER REFERENCES users(id) ON DELETE CASCADE") + except Exception: + pass # Spalte existiert bereits conn.execute(""" CREATE INDEX IF NOT EXISTS idx_ki_health_reports_dog ON ki_health_reports(dog_id, erstellt_at DESC) diff --git a/backend/main.py b/backend/main.py index 6f0fac9..dbe101c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -341,7 +341,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "806" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "807" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/routes/health.py b/backend/routes/health.py index 298ffcd..1035cf1 100644 --- a/backend/routes/health.py +++ b/backend/routes/health.py @@ -454,11 +454,14 @@ async def ki_zusammenfassung(dog_id: int, user=Depends(get_current_user)): user_is_premium=bool(user.get("is_premium")), user_id=user["id"], ) - with db() as conn: - conn.execute( - "INSERT INTO ki_health_reports (dog_id, user_id, bericht) VALUES (?,?,?)", - (dog_id, user["id"], result) - ) + try: + with db() as conn: + conn.execute( + "INSERT INTO ki_health_reports (dog_id, user_id, bericht) VALUES (?,?,?)", + (dog_id, user["id"], result) + ) + except Exception as e: + logger.warning(f"KI-Bericht konnte nicht gespeichert werden: {e}") return {"zusammenfassung": result} except KIPremiumRequired as e: raise HTTPException(402, str(e)) diff --git a/backend/static/index.html b/backend/static/index.html index 737d21e..86d0993 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -96,9 +96,9 @@ - - - + + + @@ -578,10 +578,10 @@ - - - - + + + + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 50db261..70b20ca 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '806'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '807'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; // Cache-Bust-Parameter nach Update-Reload sofort entfernen diff --git a/backend/static/sw.js b/backend/static/sw.js index 0eec8e3..a830a37 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v806'; +const CACHE_VERSION = 'by-v807'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache