Fix: ki-berichte aus SW-Cache ausgenommen, force-Reload nach Generierung, Berichte alle sichtbar (SW by-v803)

This commit is contained in:
rene 2026-05-09 20:48:35 +02:00
parent 322a9609b3
commit fbd8f0cd8f
4 changed files with 11 additions and 8 deletions

View file

@ -341,7 +341,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media")
os.makedirs(MEDIA_DIR, exist_ok=True) os.makedirs(MEDIA_DIR, exist_ok=True)
app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") 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") @app.get("/.well-known/assetlinks.json")
async def assetlinks(): async def assetlinks():

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung. 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 APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt
const IS_STAGING = location.hostname === 'staging.banyaro.app'; const IS_STAGING = location.hostname === 'staging.banyaro.app';
// Cache-Bust-Parameter nach Update-Reload sofort entfernen // Cache-Bust-Parameter nach Update-Reload sofort entfernen

View file

@ -2312,11 +2312,14 @@ window.Page_health = (() => {
// ---------------------------------------------------------- // ----------------------------------------------------------
// KI-GESUNDHEITSBERICHTE (gespeicherte automatische Berichte) // KI-GESUNDHEITSBERICHTE (gespeicherte automatische Berichte)
// ---------------------------------------------------------- // ----------------------------------------------------------
async function _loadKiBerichte(dogId) { async function _loadKiBerichte(dogId, force = false) {
const el = _container.querySelector('#health-ki-berichte'); const el = _container.querySelector('#health-ki-berichte');
if (!el) return; if (!el) return;
try { 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; if (!berichte || berichte.length === 0) return;
const neuester = berichte[0]; const neuester = berichte[0];
const datum = neuester.erstellt_at const datum = neuester.erstellt_at
@ -2795,8 +2798,8 @@ window.Page_health = (() => {
title: `${UI.icon('star')} KI-Gesundheitsbericht`, title: `${UI.icon('star')} KI-Gesundheitsbericht`,
body: `<div style="white-space:pre-wrap;line-height:1.7;font-size:var(--text-sm)">${_esc(zusammenfassung)}</div>`, body: `<div style="white-space:pre-wrap;line-height:1.7;font-size:var(--text-sm)">${_esc(zusammenfassung)}</div>`,
}); });
// Berichte-Liste nach Generierung aktualisieren // Berichte-Liste nach Generierung frisch laden (Cache-Buster)
_loadKiBerichte(_appState.activeDog.id); _loadKiBerichte(_appState.activeDog.id, true);
} catch (err) { } catch (err) {
if (err.status === 503) { if (err.status === 503) {
UI.toast.error('KI ist momentan nicht verfügbar. Bitte später erneut versuchen.'); UI.toast.error('KI ist momentan nicht verfügbar. Bitte später erneut versuchen.');

View file

@ -3,7 +3,7 @@
Offline-Cache + Push Notifications + Tile-Cache Offline-Cache + Push Notifications + Tile-Cache
============================================================ */ ============================================================ */
const CACHE_VERSION = 'by-v802'; const CACHE_VERSION = 'by-v803';
const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_STATIC = `${CACHE_VERSION}-static`;
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
@ -120,7 +120,7 @@ const _CACHEABLE_GET = [
/^\/api\/dogs(\/\d+)?$/, /^\/api\/dogs(\/\d+)?$/,
/^\/api\/dogs\/\d+\/welcome-dashboard/, /^\/api\/dogs\/\d+\/welcome-dashboard/,
/^\/api\/dogs\/\d+\/diary/, /^\/api\/dogs\/\d+\/diary/,
/^\/api\/dogs\/\d+\/health/, /^\/api\/dogs\/\d+\/health(?!\/ki-)/, // ki-berichte + ki-zusammenfassung nie cachen
/^\/api\/training\/exercises/, /^\/api\/training\/exercises/,
/^\/api\/training\/progress/, /^\/api\/training\/progress/,
/^\/api\/wiki\/rassen/, /^\/api\/wiki\/rassen/,