Debug: KI-Bericht save_count + save_error im Response, Toast-Feedback (SW by-v808)
This commit is contained in:
parent
891e11df65
commit
3acb7aa874
6 changed files with 21 additions and 12 deletions
|
|
@ -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 = "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")
|
||||
async def assetlinks():
|
||||
|
|
|
|||
|
|
@ -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_id=user["id"],
|
||||
)
|
||||
save_error = None
|
||||
try:
|
||||
with db() as conn:
|
||||
conn.execute(
|
||||
"INSERT INTO ki_health_reports (dog_id, user_id, bericht) VALUES (?,?,?)",
|
||||
(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:
|
||||
save_error = str(e)
|
||||
count = 0
|
||||
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:
|
||||
raise HTTPException(402, str(e))
|
||||
except KIUnavailableError as e:
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@
|
|||
</script>
|
||||
|
||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=807">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=807">
|
||||
<link rel="stylesheet" href="/css/components.css?v=807">
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=808">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=808">
|
||||
<link rel="stylesheet" href="/css/components.css?v=808">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -578,10 +578,10 @@
|
|||
<div id="modal-container"></div>
|
||||
|
||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||
<script src="/js/api.js?v=807"></script>
|
||||
<script src="/js/ui.js?v=807"></script>
|
||||
<script src="/js/app.js?v=807"></script>
|
||||
<script src="/js/worlds.js?v=807"></script>
|
||||
<script src="/js/api.js?v=808"></script>
|
||||
<script src="/js/ui.js?v=808"></script>
|
||||
<script src="/js/app.js?v=808"></script>
|
||||
<script src="/js/worlds.js?v=808"></script>
|
||||
|
||||
<!-- Feature-Seiten werden lazy geladen -->
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
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 IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen
|
||||
|
|
|
|||
|
|
@ -2793,7 +2793,10 @@ window.Page_health = (() => {
|
|||
UI.setLoading(btn, true);
|
||||
|
||||
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({
|
||||
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>`,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Offline-Cache + Push Notifications + Tile-Cache
|
||||
============================================================ */
|
||||
|
||||
const CACHE_VERSION = 'by-v807';
|
||||
const CACHE_VERSION = 'by-v808';
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue