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),
|
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)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user