From fbd8f0cd8f97b8a7cfb9a94fef2c264dce040301 Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 9 May 2026 20:48:35 +0200 Subject: [PATCH] Fix: ki-berichte aus SW-Cache ausgenommen, force-Reload nach Generierung, Berichte alle sichtbar (SW by-v803) --- backend/main.py | 2 +- backend/static/js/app.js | 2 +- backend/static/js/pages/health.js | 11 +++++++---- backend/static/sw.js | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/main.py b/backend/main.py index 0fb21de..b9905ab 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 = "802" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "803" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/static/js/app.js b/backend/static/js/app.js index a30eb9c..d10de0d 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 = '802'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '803'; // ← 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/js/pages/health.js b/backend/static/js/pages/health.js index 17c7155..87d6dd2 100644 --- a/backend/static/js/pages/health.js +++ b/backend/static/js/pages/health.js @@ -2312,11 +2312,14 @@ window.Page_health = (() => { // ---------------------------------------------------------- // KI-GESUNDHEITSBERICHTE (gespeicherte automatische Berichte) // ---------------------------------------------------------- - async function _loadKiBerichte(dogId) { + async function _loadKiBerichte(dogId, force = false) { const el = _container.querySelector('#health-ki-berichte'); if (!el) return; try { - const berichte = await API.health.kiBerichte(dogId); + // force=true: Cache-Buster damit SW den neuen Bericht nicht übersieht + const berichte = force + ? await API.get(`/dogs/${dogId}/health/ki-berichte?_t=${Date.now()}`) + : await API.health.kiBerichte(dogId); if (!berichte || berichte.length === 0) return; const neuester = berichte[0]; const datum = neuester.erstellt_at @@ -2795,8 +2798,8 @@ window.Page_health = (() => { title: `${UI.icon('star')} KI-Gesundheitsbericht`, body: `
${_esc(zusammenfassung)}
`, }); - // Berichte-Liste nach Generierung aktualisieren - _loadKiBerichte(_appState.activeDog.id); + // Berichte-Liste nach Generierung frisch laden (Cache-Buster) + _loadKiBerichte(_appState.activeDog.id, true); } catch (err) { if (err.status === 503) { UI.toast.error('KI ist momentan nicht verfügbar. Bitte später erneut versuchen.'); diff --git a/backend/static/sw.js b/backend/static/sw.js index 0ba2a97..6ae794e 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-v802'; +const CACHE_VERSION = 'by-v803'; 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 @@ -120,7 +120,7 @@ const _CACHEABLE_GET = [ /^\/api\/dogs(\/\d+)?$/, /^\/api\/dogs\/\d+\/welcome-dashboard/, /^\/api\/dogs\/\d+\/diary/, - /^\/api\/dogs\/\d+\/health/, + /^\/api\/dogs\/\d+\/health(?!\/ki-)/, // ki-berichte + ki-zusammenfassung nie cachen /^\/api\/training\/exercises/, /^\/api\/training\/progress/, /^\/api\/wiki\/rassen/,