add now playing to history

This commit is contained in:
2026-02-27 23:49:40 -08:00
parent 9979456719
commit d2d325ba46
2 changed files with 15 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"time"
"muzi/db"
"muzi/scrobble"
"github.com/go-chi/chi/v5"
"github.com/jackc/pgtype"
@@ -29,6 +30,8 @@ type ProfileData struct {
Title string
LoggedInUsername string
TemplateName string
NowPlayingArtist string
NowPlayingTitle string
}
// Render a page of the profile in the URL
@@ -79,6 +82,11 @@ func profilePageHandler() http.HandlerFunc {
return
}
if np, ok := scrobble.GetNowPlaying(userId); ok {
profileData.NowPlayingArtist = np.Artist
profileData.NowPlayingTitle = np.SongName
}
rows, err := db.Pool.Query(
r.Context(),
"SELECT artist, song_name, timestamp FROM history WHERE user_id = $1 ORDER BY timestamp DESC LIMIT $2 OFFSET $3;",