feat(scrobble stats): navigator lower bound, clickable rows, android button to top
- Navigator can't step before logging began: the endpoint returns firstPlayedAt (MIN(played_at) over all the user's plays, unfiltered by window); web + android disable the back arrow once the shown year/month is at/before that first play. - Top artists/tracks/albums are now clickable → open the artist / album page (web navigates and closes the overlay; android navigates via nav routes). Tracks open their album. - Android: moved the 'Meine Statistiken' button to the top of Settings (was at the bottom near logout). SW cache -> ns-v70. Android compileDebugKotlin + web build green; firstPlayedAt verified server-side. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
86eb893f40
commit
3129333f9a
8 files changed
+93
-26
No files matched your search
@@ -195,6 +195,10 @@ app.get('/scrobble/stats', async (req, res) => {
|
||||
`SELECT COUNT(*) AS plays, COALESCE(SUM(duration), 0) AS seconds FROM plays WHERE ${WHERE}`
|
||||
).get(win);
|
||||
|
||||
// Earliest play across ALL of the user's history (unfiltered by window) — lets the client cap the
|
||||
// navigator so you can't step before logging began.
|
||||
const firstPlayedAt = db.prepare('SELECT MIN(played_at) AS t FROM plays WHERE user = :user').get({ user }).t || null;
|
||||
|
||||
const topArtists = db.prepare(`
|
||||
SELECT MAX(artist) AS name, MAX(artist_id) AS artistId, COUNT(*) AS plays, COALESCE(SUM(duration),0) AS seconds
|
||||
FROM plays WHERE ${WHERE} AND artist IS NOT NULL AND artist <> ''
|
||||
@@ -231,6 +235,7 @@ app.get('/scrobble/stats', async (req, res) => {
|
||||
res.json({
|
||||
user,
|
||||
range: { from, to, tz, bucket },
|
||||
firstPlayedAt,
|
||||
totalPlays: totals.plays,
|
||||
totalSeconds: totals.seconds,
|
||||
topArtists, topAlbums, topTracks, series, byHour,
|
||||
|
||||
Reference in new issue
Block a user