mirror of
https://github.com/riwiwa/muzi.git
synced 2026-03-04 00:51:59 -08:00
add unique track count for profiles
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="user-stats-top">
|
<div class="user-stats-top">
|
||||||
<h3>{{formatInt .ScrobbleCount}}</h3> <p>Listens<p>
|
<h3>{{formatInt .ScrobbleCount}}</h3> <p>Listens<p>
|
||||||
|
<h3>{{formatInt .TrackCount}}</h3> <p>Unique Tracks<p>
|
||||||
<h3>{{formatInt .ArtistCount}}</h3> <p>Artists<p>
|
<h3>{{formatInt .ArtistCount}}</h3> <p>Artists<p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type ProfileData struct {
|
|||||||
Pfp string
|
Pfp string
|
||||||
AllowDuplicateEdits bool
|
AllowDuplicateEdits bool
|
||||||
ScrobbleCount int
|
ScrobbleCount int
|
||||||
|
TrackCount int
|
||||||
ArtistCount int
|
ArtistCount int
|
||||||
Artists []string
|
Artists []string
|
||||||
Titles []string
|
Titles []string
|
||||||
@@ -72,10 +73,11 @@ func profilePageHandler() http.HandlerFunc {
|
|||||||
r.Context(),
|
r.Context(),
|
||||||
`SELECT bio, pfp, allow_duplicate_edits,
|
`SELECT bio, pfp, allow_duplicate_edits,
|
||||||
(SELECT COUNT(*) FROM history WHERE user_id = $1) as scrobble_count,
|
(SELECT COUNT(*) FROM history WHERE user_id = $1) as scrobble_count,
|
||||||
|
(SELECT COUNT(*) FROM songs WHERE user_id = $1) as track_count,
|
||||||
(SELECT COUNT(DISTINCT artist) FROM history WHERE user_id = $1) as artist_count
|
(SELECT COUNT(DISTINCT artist) FROM history WHERE user_id = $1) as artist_count
|
||||||
FROM users WHERE pk = $1;`,
|
FROM users WHERE pk = $1;`,
|
||||||
userId,
|
userId,
|
||||||
).Scan(&profileData.Bio, &profileData.Pfp, &profileData.AllowDuplicateEdits, &profileData.ScrobbleCount, &profileData.ArtistCount)
|
).Scan(&profileData.Bio, &profileData.Pfp, &profileData.AllowDuplicateEdits, &profileData.ScrobbleCount, &profileData.TrackCount, &profileData.ArtistCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Cannot get profile for %s: %v\n", username, err)
|
fmt.Fprintf(os.Stderr, "Cannot get profile for %s: %v\n", username, err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
Reference in New Issue
Block a user