Use constants for AlbumPlayCountMode values
This commit is contained in:
parent
bc3268c144
commit
3ab66ae8ef
|
@ -45,7 +45,7 @@ type configOptions struct {
|
|||
EnableMediaFileCoverArt bool
|
||||
TranscodingCacheSize string
|
||||
ImageCacheSize string
|
||||
AlbumPlaycountMode string
|
||||
AlbumPlayCountMode string
|
||||
EnableArtworkPrecache bool
|
||||
AutoImportPlaylists bool
|
||||
PlaylistsPath string
|
||||
|
@ -290,7 +290,7 @@ func init() {
|
|||
viper.SetDefault("enabletranscodingconfig", false)
|
||||
viper.SetDefault("transcodingcachesize", "100MB")
|
||||
viper.SetDefault("imagecachesize", "100MB")
|
||||
viper.SetDefault("albumplaycountmode", "absolute")
|
||||
viper.SetDefault("albumplaycountmode", consts.AlbumPlayCountModeAbsolute)
|
||||
viper.SetDefault("enableartworkprecache", true)
|
||||
viper.SetDefault("autoimportplaylists", true)
|
||||
viper.SetDefault("playlistspath", consts.DefaultPlaylistsPath)
|
||||
|
|
|
@ -81,6 +81,11 @@ const (
|
|||
DefaultCacheCleanUpInterval = 10 * time.Minute
|
||||
)
|
||||
|
||||
const (
|
||||
AlbumPlayCountModeAbsolute = "absolute"
|
||||
AlbumPlayCountModeNormalized = "normalized"
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultDownsamplingFormat = "opus"
|
||||
DefaultTranscodings = []map[string]interface{}{
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
. "github.com/Masterminds/squirrel"
|
||||
"github.com/deluan/rest"
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/pocketbase/dbx"
|
||||
|
@ -172,7 +173,7 @@ func (r *albumRepository) GetAll(options ...model.QueryOptions) (model.Albums, e
|
|||
func (r *albumRepository) toModels(dba []dbAlbum) model.Albums {
|
||||
res := model.Albums{}
|
||||
for i := range dba {
|
||||
if conf.Server.AlbumPlaycountMode == "normalized" && dba[i].Album.SongCount != 0 {
|
||||
if conf.Server.AlbumPlayCountMode == consts.AlbumPlayCountModeNormalized && dba[i].Album.SongCount != 0 {
|
||||
dba[i].Album.PlayCount = (dba[i].Album.PlayCount + (int64(dba[i].Album.SongCount) - 1)) / int64(dba[i].Album.SongCount)
|
||||
}
|
||||
res = append(res, *dba[i].Album)
|
||||
|
|
Loading…
Reference in New Issue