mirror of
https://github.com/riwiwa/muzi.git
synced 2026-02-28 11:56:57 -08:00
add now playing to history
This commit is contained in:
@@ -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;",
|
||||
|
||||
Reference in New Issue
Block a user