1
0

Updated CheckAndUpdateMostListenedSong() to work with a new Song struct.

This commit is contained in:
Alexander Andreev 2023-10-02 03:19:23 +04:00
parent 58b3d18288
commit bd9b80076a
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -47,15 +47,14 @@ var mostListened MostListenedSong
// So it would be fairer to give these listeners back to a song they was // So it would be fairer to give these listeners back to a song they was
// listening to. // listening to.
func CheckAndUpdateMostListenedSong(cur, prev *Song) { func CheckAndUpdateMostListenedSong(cur, prev *Song) {
if prev.Song == "" { if prev.Artist == "" {
return return
} }
l, _ := strconv.Atoi(cur.Listeners) if cur.MaxListeners > mostListened.Listeners {
if l > mostListened.Listeners {
mostListened = MostListenedSong{ mostListened = MostListenedSong{
Listeners: l, Listeners: cur.MaxListeners,
Date: time.Now().UTC(), Date: time.Now().UTC(),
Song: prev.Song} Song: prev.ArtistTitle()}
} }
mlsChanged = true mlsChanged = true
} }