mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Add feature flag for buffered scrobbling
This commit is contained in:
parent
cfb113bd33
commit
f49205733b
3 changed files with 12 additions and 8 deletions
|
@ -70,6 +70,7 @@ type configOptions struct {
|
|||
DevOldCacheLayout bool
|
||||
DevActivityPanel bool
|
||||
DevEnableShare bool
|
||||
DevEnableBufferedScrobble bool
|
||||
}
|
||||
|
||||
type scannerOptions struct {
|
||||
|
@ -229,6 +230,7 @@ func init() {
|
|||
viper.SetDefault("devfastaccesscoverart", false)
|
||||
viper.SetDefault("devactivitypanel", true)
|
||||
viper.SetDefault("devenableshare", false)
|
||||
viper.SetDefault("devenablebufferedscrobble", false)
|
||||
}
|
||||
|
||||
func InitConfig(cfgFile string) {
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
|
||||
"github.com/ReneKroon/ttlcache/v2"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
|
@ -50,7 +52,9 @@ func GetPlayTracker(ds model.DataStore, broker events.Broker) PlayTracker {
|
|||
p.scrobblers = make(map[string]Scrobbler)
|
||||
for name, constructor := range constructors {
|
||||
s := constructor(ds)
|
||||
s = NewBufferedScrobbler(ds, s, name)
|
||||
if conf.Server.DevEnableBufferedScrobble {
|
||||
s = NewBufferedScrobbler(ds, s, name)
|
||||
}
|
||||
p.scrobblers[name] = s
|
||||
}
|
||||
return p
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/server/events"
|
||||
|
@ -23,6 +25,9 @@ var _ = Describe("PlayTracker", func() {
|
|||
var fake fakeScrobbler
|
||||
|
||||
BeforeEach(func() {
|
||||
// Remove buffering to simplify tests
|
||||
conf.Server.DevEnableBufferedScrobble = false
|
||||
|
||||
ctx = context.Background()
|
||||
ctx = request.WithUser(ctx, model.User{ID: "u-1"})
|
||||
ctx = request.WithPlayer(ctx, model.Player{ScrobbleEnabled: true})
|
||||
|
@ -33,13 +38,6 @@ var _ = Describe("PlayTracker", func() {
|
|||
})
|
||||
tracker = GetPlayTracker(ds, events.GetBroker())
|
||||
|
||||
// Remove buffering to simplify tests
|
||||
for i, s := range tracker.(*playTracker).scrobblers {
|
||||
if bs, ok := s.(*bufferedScrobbler); ok {
|
||||
tracker.(*playTracker).scrobblers[i] = bs.wrapped
|
||||
}
|
||||
}
|
||||
|
||||
track = model.MediaFile{
|
||||
ID: "123",
|
||||
Title: "Track Title",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue