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), Duration: oggtag.GetDuration(bs, be),
MaxListeners: dj.listeners.Current(), MaxListeners: dj.listeners.Current(),
StartAt: time.Now()} StartAt: time.Now()}
// radio.CheckAndUpdateMostListenedSong(song, currentSong) radio.CheckAndUpdateMostListenedSong(dj.songList.Current())
dj.songList.Add(song) 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 // 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 *Song) {
if prev.Artist == "" { if cur == nil || cur.Artist == "" {
return return
} }
if cur.MaxListeners > mostListened.Listeners { if cur.MaxListeners > mostListened.Listeners {
mostListened = MostListenedSong{ mostListened = MostListenedSong{
Listeners: cur.MaxListeners, Listeners: cur.MaxListeners,
Date: time.Now().UTC(), Date: cur.StartAt,
Song: prev.ArtistTitle()} Song: cur.ArtistTitle()}
} }
mlsChanged = true mlsChanged = true
} }