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:
@@ -20,6 +20,13 @@
|
|||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Timestamp</th>
|
<th>Timestamp</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
{{if .NowPlayingTitle}}
|
||||||
|
<tr>
|
||||||
|
<td>{{.NowPlayingArtist}}</td>
|
||||||
|
<td>{{.NowPlayingTitle}}</td>
|
||||||
|
<td>Now Playing</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
{{$artists := .Artists}}
|
{{$artists := .Artists}}
|
||||||
{{$times := .Times}}
|
{{$times := .Times}}
|
||||||
{{range $index, $title := .Titles}}
|
{{range $index, $title := .Titles}}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"muzi/db"
|
"muzi/db"
|
||||||
|
"muzi/scrobble"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/jackc/pgtype"
|
"github.com/jackc/pgtype"
|
||||||
@@ -29,6 +30,8 @@ type ProfileData struct {
|
|||||||
Title string
|
Title string
|
||||||
LoggedInUsername string
|
LoggedInUsername string
|
||||||
TemplateName string
|
TemplateName string
|
||||||
|
NowPlayingArtist string
|
||||||
|
NowPlayingTitle string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render a page of the profile in the URL
|
// Render a page of the profile in the URL
|
||||||
@@ -79,6 +82,11 @@ func profilePageHandler() http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if np, ok := scrobble.GetNowPlaying(userId); ok {
|
||||||
|
profileData.NowPlayingArtist = np.Artist
|
||||||
|
profileData.NowPlayingTitle = np.SongName
|
||||||
|
}
|
||||||
|
|
||||||
rows, err := db.Pool.Query(
|
rows, err := db.Pool.Query(
|
||||||
r.Context(),
|
r.Context(),
|
||||||
"SELECT artist, song_name, timestamp FROM history WHERE user_id = $1 ORDER BY timestamp DESC LIMIT $2 OFFSET $3;",
|
"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