1
0

Updated CheckAndUpdateMostListenedSong() func.

This commit is contained in:
Alexander Andreev 2023-10-02 15:04:51 +04:00
parent 1990f1c7f0
commit 64c2868fcf
Signed by: Arav
GPG Key ID: D22A817D95815393
2 changed files with 5 additions and 5 deletions

View File

@ -68,7 +68,7 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) {
Duration: oggtag.GetDuration(bs, be),
MaxListeners: dj.listeners.Current(),
StartAt: time.Now()}
// radio.CheckAndUpdateMostListenedSong(song, currentSong)
radio.CheckAndUpdateMostListenedSong(dj.songList.Current())
dj.songList.Add(song)
}()
}

View File

@ -46,15 +46,15 @@ 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.Artist == "" {
func CheckAndUpdateMostListenedSong(cur *Song) {
if cur == nil || cur.Artist == "" {
return
}
if cur.MaxListeners > mostListened.Listeners {
mostListened = MostListenedSong{
Listeners: cur.MaxListeners,
Date: time.Now().UTC(),
Song: prev.ArtistTitle()}
Date: cur.StartAt,
Song: cur.ArtistTitle()}
}
mlsChanged = true
}