Debug: KI-Bericht save_count + save_error im Response, Toast-Feedback (SW by-v808)

This commit is contained in:
rene 2026-05-09 21:38:35 +02:00
parent 891e11df65
commit 3acb7aa874
6 changed files with 21 additions and 12 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 = "807" # muss mit APP_VER in app.js übereinstimmen APP_VER = "808" # 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

@ -454,15 +454,21 @@ async def ki_zusammenfassung(dog_id: int, user=Depends(get_current_user)):
user_is_premium=bool(user.get("is_premium")), user_is_premium=bool(user.get("is_premium")),
user_id=user["id"], user_id=user["id"],
) )
save_error = None
try: try:
with db() as conn: with db() as conn:
conn.execute( conn.execute(
"INSERT INTO ki_health_reports (dog_id, user_id, bericht) VALUES (?,?,?)", "INSERT INTO ki_health_reports (dog_id, user_id, bericht) VALUES (?,?,?)",
(dog_id, user["id"], result) (dog_id, user["id"], result)
) )
count = conn.execute(
"SELECT COUNT(*) FROM ki_health_reports WHERE dog_id=?", (dog_id,)
).fetchone()[0]
except Exception as e: except Exception as e:
save_error = str(e)
count = 0
logger.warning(f"KI-Bericht konnte nicht gespeichert werden: {e}") logger.warning(f"KI-Bericht konnte nicht gespeichert werden: {e}")
return {"zusammenfassung": result} return {"zusammenfassung": result, "saved_count": count, "save_error": save_error}
except KIPremiumRequired as e: except KIPremiumRequired as e:
raise HTTPException(402, str(e)) raise HTTPException(402, str(e))
except KIUnavailableError as e: except KIUnavailableError as e:

View file

@ -96,9 +96,9 @@
</script> </script>
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung --> <!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
<link rel="stylesheet" href="/css/design-system.css?v=807"> <link rel="stylesheet" href="/css/design-system.css?v=808">
<link rel="stylesheet" href="/css/layout.css?v=807"> <link rel="stylesheet" href="/css/layout.css?v=808">
<link rel="stylesheet" href="/css/components.css?v=807"> <link rel="stylesheet" href="/css/components.css?v=808">
</head> </head>
<body> <body>
@ -578,10 +578,10 @@
<div id="modal-container"></div> <div id="modal-container"></div>
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features --> <!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
<script src="/js/api.js?v=807"></script> <script src="/js/api.js?v=808"></script>
<script src="/js/ui.js?v=807"></script> <script src="/js/ui.js?v=808"></script>
<script src="/js/app.js?v=807"></script> <script src="/js/app.js?v=808"></script>
<script src="/js/worlds.js?v=807"></script> <script src="/js/worlds.js?v=808"></script>
<!-- Feature-Seiten werden lazy geladen --> <!-- Feature-Seiten werden lazy geladen -->

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung. Router, State-Management, Navigation, Initialisierung.
============================================================ */ ============================================================ */
const APP_VER = '807'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VER = '808'; // ← 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

@ -2793,7 +2793,10 @@ window.Page_health = (() => {
UI.setLoading(btn, true); UI.setLoading(btn, true);
try { try {
const { zusammenfassung } = await API.health.kiZusammenfassung(_appState.activeDog.id); const res = await API.health.kiZusammenfassung(_appState.activeDog.id);
const zusammenfassung = res.zusammenfassung ?? res;
if (res.save_error) UI.toast.warning(`Speichern fehlgeschlagen: ${res.save_error}`);
else if (res.saved_count !== undefined) UI.toast.info(`${res.saved_count} Bericht(e) gespeichert`);
UI.modal.open({ UI.modal.open({
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>`,

View file

@ -3,7 +3,7 @@
Offline-Cache + Push Notifications + Tile-Cache Offline-Cache + Push Notifications + Tile-Cache
============================================================ */ ============================================================ */
const CACHE_VERSION = 'by-v807'; const CACHE_VERSION = 'by-v808';
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