From 07db68aea2cda463a5cb2c39d2ebb75380b599f7 Mon Sep 17 00:00:00 2001 From: rene Date: Thu, 14 May 2026 22:00:52 +0200 Subject: [PATCH] Fix: Geburtstag aller Hunde + Kotbeutel-Stationen in Stats (SW by-v962) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - worlds.js: bdayDog = _dogs.find(...) — Geburtstag gilt für alle Hunde, nicht nur den aktiven - Banner, KI-Call, "Was hat sich X gewünscht?" nutzen bdayDog.name - stats.py: kotbeutel-Count aus user_map_pois WHERE type='kotbeutel' - landing: Stats-Band 5. Kachel "Kotbeutel-Stationen" --- backend/main.py | 2 +- backend/routes/stats.py | 14 +++++++++----- backend/static/js/app.js | 2 +- backend/static/js/worlds.js | 19 ++++++++++--------- backend/static/landing.html | 7 ++++++- backend/static/sw.js | 2 +- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/backend/main.py b/backend/main.py index f1025de..533923e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -406,7 +406,7 @@ async def serve_media(path: str, request: _Request): raise _HE(404, "Nicht gefunden.") return _media_response(filepath) -APP_VER = "961" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "962" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/routes/stats.py b/backend/routes/stats.py index 49fe778..cfaecca 100644 --- a/backend/routes/stats.py +++ b/backend/routes/stats.py @@ -30,19 +30,23 @@ async def public_stats(): if _pub_cache["data"] and now - _pub_cache["ts"] < _PUB_TTL: return _pub_cache["data"] with db() as conn: - users = conn.execute("SELECT COUNT(*) FROM users").fetchone()[0] - dogs = conn.execute("SELECT COUNT(*) FROM dogs").fetchone()[0] - km = conn.execute( + users = conn.execute("SELECT COUNT(*) FROM users").fetchone()[0] + dogs = conn.execute("SELECT COUNT(*) FROM dogs").fetchone()[0] + km = conn.execute( "SELECT ROUND(COALESCE(SUM(distanz_km),0),0) FROM routes" ).fetchone()[0] - posts = conn.execute("SELECT COUNT(*) FROM forum_posts").fetchone()[0] - diary = conn.execute("SELECT COUNT(*) FROM diary").fetchone()[0] + posts = conn.execute("SELECT COUNT(*) FROM forum_posts").fetchone()[0] + diary = conn.execute("SELECT COUNT(*) FROM diary").fetchone()[0] + kotbeutel = conn.execute( + "SELECT COUNT(*) FROM user_map_pois WHERE type='kotbeutel'" + ).fetchone()[0] data = { "users": users, "dogs": dogs, "km": int(km or 0), "forum_posts": posts, "diary_entries": diary, + "kotbeutel": kotbeutel, } _pub_cache["data"] = data _pub_cache["ts"] = now diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 6594b45..f630663 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 = '961'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '962'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.1'; // ← 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/worlds.js b/backend/static/js/worlds.js index b250a29..ca5fdce 100644 --- a/backend/static/js/worlds.js +++ b/backend/static/js/worlds.js @@ -1342,8 +1342,9 @@ window.Worlds = (() => { if (mmdd === `${mt}-${dt}`) return 'tomorrow'; return null; } - const bday = _birthdayState(dog.geburtstag); - const bdayYear = dog.geburtstag ? new Date().getFullYear() - parseInt(dog.geburtstag.slice(0, 4)) : null; + const bdayDog = _dogs.find(d => _birthdayState(d.geburtstag)) || null; + const bday = bdayDog ? _birthdayState(bdayDog.geburtstag) : null; + const bdayYear = bdayDog?.geburtstag ? new Date().getFullYear() - parseInt(bdayDog.geburtstag.slice(0, 4)) : null; const [streakRes, diaryRes] = await Promise.allSettled([ _cachedGet(`streak_${dog.id}`, `/streak/${dog.id}`), @@ -1428,8 +1429,8 @@ window.Worlds = (() => {
${bday === 'today' - ? `Alles Gute zum ${bdayYear}. Geburtstag, ${_esc(dog.name)}!` - : `Morgen hat ${_esc(dog.name)} Geburtstag!`} + ? `Alles Gute zum ${bdayYear}. Geburtstag, ${_esc(bdayDog.name)}!` + : `Morgen hat ${_esc(bdayDog.name)} Geburtstag!`}
@@ -1443,7 +1444,7 @@ window.Worlds = (() => {
` : ''}
- ${bday === 'today' ? 'Was hat sich Ban Yaro gewünscht?' : 'KI-Überraschungsideen'} + ${bday === 'today' ? `Was hat sich ${_esc(bdayDog.name)} gewünscht?` : 'KI-Überraschungsideen'}
${bday === 'today' && new Date().getHours() >= 18 ? ` @@ -1563,10 +1564,10 @@ window.Worlds = (() => { try { const res = await API.post('/ki/geburtstag', { - dog_id: dog.id, - name: dog.name, - rasse: dog.rasse || null, - alter: dog.alter_jahre ? Math.round(dog.alter_jahre) : null, + dog_id: bdayDog.id, + name: bdayDog.name, + rasse: bdayDog.rasse || null, + alter: bdayDog.alter_jahre ? Math.round(bdayDog.alter_jahre) : null, mode: bdayMode, }); const body = ov.querySelector('#bday-ki-body'); diff --git a/backend/static/landing.html b/backend/static/landing.html index 49a2a5d..9e68f67 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -824,6 +824,10 @@
Forum-Beiträge
+
+
+
Kotbeutel-Stationen
+
@@ -1579,7 +1583,8 @@ set('big-users', d.users); set('big-dogs', d.dogs); set('big-km', d.km); - set('big-posts', d.forum_posts); + set('big-posts', d.forum_posts); + set('big-kotbeutel', d.kotbeutel); var heroStats = document.getElementById('hero-stats'); if (heroStats && d.users > 0) heroStats.style.display = 'flex'; diff --git a/backend/static/sw.js b/backend/static/sw.js index ddcd02a..16dc02a 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-v961'; +const CACHE_VERSION = 'by-v962'; 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