Updated CheckAndUpdateMostListenedSong() func.
This commit is contained in:
parent
1990f1c7f0
commit
64c2868fcf
@ -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)
|
||||
}()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user