fix(ui): sort mappings (#3296)

* fix(ui): update sort mapping for title in mediafile repository

* fix(ui): create sort mapping for username in share repository

* fix(ui): create sort mapping for owner_name in playlist repository

* fix(ui): create sort mapping for username in player repository

* fix(ui): remove sort mapping for track number in mediafile repository

* chore: add todo to change user_name
This commit is contained in:
Caio Cotts 2024-09-20 21:36:59 -04:00 committed by GitHub
parent e628aafa4b
commit 11d96f1da4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 14 deletions

View file

@ -33,23 +33,21 @@ func NewMediaFileRepository(ctx context.Context, db dbx.Builder) *mediaFileRepos
})
if conf.Server.PreferSortTags {
r.sortMappings = map[string]string{
"title": "COALESCE(NULLIF(sort_title,''),title)",
"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",
"random": "random",
"created_at": "media_file.created_at",
"track_number": "album, release_date, disc_number, track_number",
"starred_at": "starred, starred_at",
"title": "COALESCE(NULLIF(sort_title,''),order_title)",
"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",
"random": "random",
"created_at": "media_file.created_at",
"starred_at": "starred, starred_at",
}
} else {
r.sortMappings = map[string]string{
"title": "order_title",
"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",
"random": "random",
"created_at": "media_file.created_at",
"track_number": "album, release_date, disc_number, track_number",
"starred_at": "starred, starred_at",
"title": "order_title",
"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",
"random": "random",
"created_at": "media_file.created_at",
"starred_at": "starred, starred_at",
}
}
return r

View file

@ -21,6 +21,9 @@ func NewPlayerRepository(ctx context.Context, db dbx.Builder) model.PlayerReposi
r.registerModel(&model.Player{}, map[string]filterFunc{
"name": containsFilter("player.name"),
})
r.sortMappings = map[string]string{
"user_name": "username", //TODO rename all user_name and userName to username
}
return r
}

View file

@ -55,6 +55,9 @@ func NewPlaylistRepository(ctx context.Context, db dbx.Builder) model.PlaylistRe
"q": playlistFilter,
"smart": smartPlaylistFilter,
})
r.sortMappings = map[string]string{
"owner_name": "owner_name",
}
return r
}

View file

@ -24,6 +24,9 @@ func NewShareRepository(ctx context.Context, db dbx.Builder) model.ShareReposito
r.ctx = ctx
r.db = db
r.registerModel(&model.Share{}, map[string]filterFunc{})
r.sortMappings = map[string]string{
"username": "username",
}
return r
}