mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-01 19:47:37 +03:00
fix(subsonic): getRandomSongs with genre
filter
fix https://github.com/dweymouth/supersonic/issues/577 Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
0bb4b881e9
commit
7c13878075
2 changed files with 10 additions and 18 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/id"
|
||||
|
@ -53,17 +52,6 @@ var _ = Describe("MediaRepository", func() {
|
|||
Expect(err).To(MatchError(model.ErrNotFound))
|
||||
})
|
||||
|
||||
XIt("filters by genre", func() {
|
||||
Expect(mr.GetAll(model.QueryOptions{
|
||||
Sort: "genre.name asc, title asc",
|
||||
Filters: squirrel.Eq{"genre.name": "Rock"},
|
||||
})).To(Equal(model.MediaFiles{
|
||||
songDayInALife,
|
||||
songAntenna,
|
||||
songComeTogether,
|
||||
}))
|
||||
})
|
||||
|
||||
Context("Annotations", func() {
|
||||
It("increments play count when the tracks does not have annotations", func() {
|
||||
id := "incplay.firsttime"
|
||||
|
|
|
@ -95,7 +95,7 @@ func SongsByRandom(genre string, fromYear, toYear int) Options {
|
|||
}
|
||||
ff := And{}
|
||||
if genre != "" {
|
||||
ff = append(ff, Eq{"genre.name": genre})
|
||||
ff = append(ff, filterByGenre(genre))
|
||||
}
|
||||
if fromYear != 0 {
|
||||
ff = append(ff, GtOrEq{"year": fromYear})
|
||||
|
@ -118,11 +118,15 @@ func SongWithLyrics(artist, title string) Options {
|
|||
|
||||
func ByGenre(genre string) Options {
|
||||
return addDefaultFilters(Options{
|
||||
Sort: "name asc",
|
||||
Filters: persistence.Exists("json_tree(tags)", And{
|
||||
Like{"value": genre},
|
||||
NotEq{"atom": nil},
|
||||
}),
|
||||
Sort: "name asc",
|
||||
Filters: filterByGenre(genre),
|
||||
})
|
||||
}
|
||||
|
||||
func filterByGenre(genre string) Sqlizer {
|
||||
return persistence.Exists("json_tree(tags)", And{
|
||||
Like{"value": genre},
|
||||
NotEq{"atom": nil},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue