From d1558cf352f24c311b8505661143973d11d9edba Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 21 Jul 2023 15:56:34 +0200 Subject: backend: support an incremental time bonus --- wrms.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'wrms.go') diff --git a/wrms.go b/wrms.go index a345767..1f1332e 100644 --- a/wrms.go +++ b/wrms.go @@ -18,7 +18,7 @@ type Song struct { Artist string `json:"artist"` Source string `json:"source"` Uri string `json:"uri"` - Weight int `json:"weight"` + Weight float64 `json:"weight"` Album string `json:"album"` Year int `json:"year"` index int `json:"-"` // used by heap.Interface @@ -296,6 +296,11 @@ func (wrms *Wrms) AddSong(song Song) { s := &wrms.Songs[len(wrms.Songs)-1] wrms.queue.Add(s) + if wrms.Config.timeBonus != 0 { + llog.Info("Apply time bonus %v", wrms.Config.timeBonus) + wrms.queue.applyTimeBonus(wrms.Config.timeBonus) + } + wrms.rwlock.Unlock() llog.Info("Added song %s (ptr=%p) to Songs", s.Uri, s) -- cgit v1.2.3