From bd9b80076ada01da0cbb0b1ec61f0b8157d06b35 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 2 Oct 2023 03:19:23 +0400 Subject: [PATCH] Updated CheckAndUpdateMostListenedSong() to work with a new Song struct. --- internal/radio/mostlistened.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/radio/mostlistened.go b/internal/radio/mostlistened.go index 7e6d397..34853f8 100644 --- a/internal/radio/mostlistened.go +++ b/internal/radio/mostlistened.go @@ -47,15 +47,14 @@ var mostListened MostListenedSong // So it would be fairer to give these listeners back to a song they was // listening to. func CheckAndUpdateMostListenedSong(cur, prev *Song) { - if prev.Song == "" { + if prev.Artist == "" { return } - l, _ := strconv.Atoi(cur.Listeners) - if l > mostListened.Listeners { + if cur.MaxListeners > mostListened.Listeners { mostListened = MostListenedSong{ - Listeners: l, + Listeners: cur.MaxListeners, Date: time.Now().UTC(), - Song: prev.Song} + Song: prev.ArtistTitle()} } mlsChanged = true }