mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-05 05:27:37 +03:00
Add new PrefSortTags option (#2696)
This commit is contained in:
parent
d3669f46a9
commit
ab53313273
4 changed files with 38 additions and 14 deletions
|
@ -51,6 +51,7 @@ type configOptions struct {
|
||||||
DefaultDownsamplingFormat string
|
DefaultDownsamplingFormat string
|
||||||
SearchFullString bool
|
SearchFullString bool
|
||||||
RecentlyAddedByModTime bool
|
RecentlyAddedByModTime bool
|
||||||
|
PreferSortTags bool
|
||||||
IgnoredArticles string
|
IgnoredArticles string
|
||||||
IndexGroups string
|
IndexGroups string
|
||||||
SubsonicArtistParticipations bool
|
SubsonicArtistParticipations bool
|
||||||
|
@ -296,6 +297,7 @@ func init() {
|
||||||
viper.SetDefault("defaultdownsamplingformat", consts.DefaultDownsamplingFormat)
|
viper.SetDefault("defaultdownsamplingformat", consts.DefaultDownsamplingFormat)
|
||||||
viper.SetDefault("searchfullstring", false)
|
viper.SetDefault("searchfullstring", false)
|
||||||
viper.SetDefault("recentlyaddedbymodtime", false)
|
viper.SetDefault("recentlyaddedbymodtime", false)
|
||||||
|
viper.SetDefault("prefersorttags", false)
|
||||||
viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A")
|
viper.SetDefault("ignoredarticles", "The El La Los Las Le Les Os As O A")
|
||||||
viper.SetDefault("indexgroups", "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ) [Unknown]([)")
|
viper.SetDefault("indexgroups", "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ) [Unknown]([)")
|
||||||
viper.SetDefault("subsonicartistparticipations", false)
|
viper.SetDefault("subsonicartistparticipations", false)
|
||||||
|
|
|
@ -50,13 +50,6 @@ func NewAlbumRepository(ctx context.Context, db dbx.Builder) model.AlbumReposito
|
||||||
r.ctx = ctx
|
r.ctx = ctx
|
||||||
r.db = db
|
r.db = db
|
||||||
r.tableName = "album"
|
r.tableName = "album"
|
||||||
r.sortMappings = map[string]string{
|
|
||||||
"name": "order_album_name asc, order_album_artist_name asc",
|
|
||||||
"artist": "compilation asc, order_album_artist_name asc, order_album_name asc",
|
|
||||||
"random": "RANDOM()",
|
|
||||||
"max_year": "coalesce(nullif(original_date,''), cast(max_year as text)), release_date, name, order_album_name asc",
|
|
||||||
"recently_added": recentlyAddedSort(),
|
|
||||||
}
|
|
||||||
r.filterMappings = map[string]filterFunc{
|
r.filterMappings = map[string]filterFunc{
|
||||||
"id": idFilter(r.tableName),
|
"id": idFilter(r.tableName),
|
||||||
"name": fullTextFilter,
|
"name": fullTextFilter,
|
||||||
|
@ -67,6 +60,21 @@ func NewAlbumRepository(ctx context.Context, db dbx.Builder) model.AlbumReposito
|
||||||
"starred": booleanFilter,
|
"starred": booleanFilter,
|
||||||
"has_rating": hasRatingFilter,
|
"has_rating": hasRatingFilter,
|
||||||
}
|
}
|
||||||
|
r.sortMappings = map[string]string{
|
||||||
|
"name": "order_album_name asc, order_album_artist_name asc",
|
||||||
|
"artist": "compilation asc, order_album_artist_name asc, order_album_name asc",
|
||||||
|
"random": "RANDOM()",
|
||||||
|
"max_year": "coalesce(nullif(original_date,''), cast(max_year as text)), release_date, name, order_album_name asc",
|
||||||
|
"recently_added": recentlyAddedSort(),
|
||||||
|
}
|
||||||
|
if conf.Server.PreferSortTags {
|
||||||
|
r.sortMappings = map[string]string{
|
||||||
|
"name": "COALESCE(NULLIF(sort_album_name,''),order_album_name)",
|
||||||
|
"artist": "compilation asc, COALESCE(NULLIF(sort_album_artist_name,''),order_album_artist_name) asc, COALESCE(NULLIF(sort_album_name,''),order_album_name) asc",
|
||||||
|
"albumArtist": "compilation asc, COALESCE(NULLIF(sort_album_artist_name,''),order_album_artist_name) asc, COALESCE(NULLIF(sort_album_name,''),order_album_name) asc",
|
||||||
|
"max_year": "coalesce(nullif(original_date,''), cast(max_year as text)), release_date, name, COALESCE(NULLIF(sort_album_name,''),order_album_name) asc",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,14 +60,20 @@ func NewArtistRepository(ctx context.Context, db dbx.Builder) model.ArtistReposi
|
||||||
r.db = db
|
r.db = db
|
||||||
r.indexGroups = utils.ParseIndexGroups(conf.Server.IndexGroups)
|
r.indexGroups = utils.ParseIndexGroups(conf.Server.IndexGroups)
|
||||||
r.tableName = "artist"
|
r.tableName = "artist"
|
||||||
r.sortMappings = map[string]string{
|
|
||||||
"name": "order_artist_name",
|
|
||||||
}
|
|
||||||
r.filterMappings = map[string]filterFunc{
|
r.filterMappings = map[string]filterFunc{
|
||||||
"id": idFilter(r.tableName),
|
"id": idFilter(r.tableName),
|
||||||
"name": fullTextFilter,
|
"name": fullTextFilter,
|
||||||
"starred": booleanFilter,
|
"starred": booleanFilter,
|
||||||
}
|
}
|
||||||
|
if conf.Server.PreferSortTags {
|
||||||
|
r.sortMappings = map[string]string{
|
||||||
|
"name": "COALESCE(NULLIF(sort_artist_name,''),order_artist_name)",
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r.sortMappings = map[string]string{
|
||||||
|
"name": "order_artist_name",
|
||||||
|
}
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
. "github.com/Masterminds/squirrel"
|
. "github.com/Masterminds/squirrel"
|
||||||
"github.com/deluan/rest"
|
"github.com/deluan/rest"
|
||||||
|
"github.com/navidrome/navidrome/conf"
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/model"
|
"github.com/navidrome/navidrome/model"
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
|
@ -25,15 +26,22 @@ func NewMediaFileRepository(ctx context.Context, db dbx.Builder) *mediaFileRepos
|
||||||
r.ctx = ctx
|
r.ctx = ctx
|
||||||
r.db = db
|
r.db = db
|
||||||
r.tableName = "media_file"
|
r.tableName = "media_file"
|
||||||
|
r.filterMappings = map[string]filterFunc{
|
||||||
|
"id": idFilter(r.tableName),
|
||||||
|
"title": fullTextFilter,
|
||||||
|
"starred": booleanFilter,
|
||||||
|
}
|
||||||
r.sortMappings = map[string]string{
|
r.sortMappings = map[string]string{
|
||||||
"artist": "order_artist_name asc, order_album_name asc, release_date asc, disc_number asc, track_number asc",
|
"artist": "order_artist_name asc, order_album_name asc, release_date asc, disc_number asc, track_number asc",
|
||||||
"album": "order_album_name asc, release_date asc, disc_number asc, track_number asc, order_artist_name asc, title asc",
|
"album": "order_album_name asc, release_date asc, disc_number asc, track_number asc, order_artist_name asc, title asc",
|
||||||
"random": "RANDOM()",
|
"random": "RANDOM()",
|
||||||
}
|
}
|
||||||
r.filterMappings = map[string]filterFunc{
|
if conf.Server.PreferSortTags {
|
||||||
"id": idFilter(r.tableName),
|
r.sortMappings = map[string]string{
|
||||||
"title": fullTextFilter,
|
"title": "COALESCE(NULLIF(sort_title,''),title)",
|
||||||
"starred": booleanFilter,
|
"artist": "COALESCE(NULLIF(sort_artist_name,''),order_artist_name) asc, COALESCE(NULLIF(sort_album_name,''),order_album_name) asc, release_date asc, disc_number asc, track_number asc",
|
||||||
|
"album": "COALESCE(NULLIF(sort_album_name,''),order_album_name) asc, release_date asc, disc_number asc, track_number asc, COALESCE(NULLIF(sort_artist_name,''),order_artist_name) asc, COALESCE(NULLIF(sort_title,''),title) asc",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue