diff --git a/VERSION b/VERSION index a899ac6..8535dde 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1160 \ No newline at end of file +1161 \ No newline at end of file diff --git a/backend/routes/routen.py b/backend/routes/routen.py index 0e81704..db57d55 100644 --- a/backend/routes/routen.py +++ b/backend/routes/routen.py @@ -95,6 +95,7 @@ async def list_routes( radius: int = 10000, user = Depends(get_current_user_optional), ): + _uid = user['id'] if user else -1 with db() as conn: rows = conn.execute(""" SELECT r.id, r.user_id, r.name, r.beschreibung, @@ -106,11 +107,13 @@ async def list_routes( json_extract(r.gps_track, '$[0].lat') AS start_lat, json_extract(r.gps_track, '$[0].lon') AS start_lon, json_extract(r.gps_track, '$[#-1].lat') AS end_lat, - json_extract(r.gps_track, '$[#-1].lon') AS end_lon + json_extract(r.gps_track, '$[#-1].lon') AS end_lon, + (SELECT COUNT(*) FROM route_walks w WHERE w.route_id=r.id AND w.user_id=?) AS my_walk_count, + (SELECT MAX(walked_at) FROM route_walks w WHERE w.route_id=r.id AND w.user_id=?) AS my_last_walked FROM routes r LEFT JOIN users u ON u.id = r.user_id ORDER BY r.created_at DESC - """).fetchall() + """, (_uid, _uid)).fetchall() result = [] for row in rows: @@ -492,7 +495,13 @@ async def record_walk(route_id: int, body: WalkRecord, user=Depends(get_current_ ) update_streak(uid, conn) new_badges = check_and_award(uid, conn) - return {"ok": True, "new_badges": new_badges} + total_km = conn.execute( + "SELECT ROUND(" + " COALESCE((SELECT SUM(distanz_km) FROM routes WHERE user_id=? AND is_valid=1),0) +" + " COALESCE((SELECT SUM(walked_km) FROM route_walks WHERE user_id=?),0), 1)", + (uid, uid) + ).fetchone()[0] + return {"ok": True, "new_badges": new_badges, "total_km": total_km} # ------------------------------------------------------------------ diff --git a/backend/static/index.html b/backend/static/index.html index 1689eef..950d38a 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 4e69472..23c0284 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 = '1160'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1161'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/pages/routes.js b/backend/static/js/pages/routes.js index 1632259..357a1e5 100644 --- a/backend/static/js/pages/routes.js +++ b/backend/static/js/pages/routes.js @@ -1442,6 +1442,20 @@ window.Page_routes = (() => { ? `
${UI.icon('user')} ${UI.escape(r.user_name||'Anonym')}
` : ''; + // „X× gelaufen · zuletzt …" — macht sichtbar, dass das Ablaufen mitzählt + const _wc = r.my_walk_count || 0; + let walkedLine = ''; + if (_wc > 0) { + let last = ''; + if (r.my_last_walked) { + const d = new Date(String(r.my_last_walked).replace(' ', 'T') + 'Z'); // walked_at ist UTC + const days = Math.floor((Date.now() - d.getTime()) / 86400000); + last = days <= 0 ? 'heute' : days === 1 ? 'gestern' : `vor ${days} Tagen`; + } + walkedLine = `
+ 🐾 ${_wc}× gelaufen${last ? ' · zuletzt ' + last : ''}
`; + } + return `
${previewContent}
@@ -1461,6 +1475,7 @@ window.Page_routes = (() => { ${r.hunde_tauglichkeit ? _pill(HUNDE_TEXT[r.hunde_tauglichkeit]||'', 'rgba(234,179,8,0.10)','#facc15','rgba(234,179,8,0.30)') : ''} ${!isDiscover && !r.is_public ? _pill('Privat','rgba(59,130,246,0.10)','#60a5fa','rgba(59,130,246,0.30)') : ''}
+ ${walkedLine}