Add "random" sort option for Smart Playlists

This commit is contained in:
Deluan 2022-02-09 09:39:42 -05:00
parent e966d94c0b
commit 50ff8bcce7
2 changed files with 7 additions and 0 deletions

View File

@ -81,4 +81,10 @@ var _ = Describe("Criteria", func() {
gomega.Expect(string(j)).To(gomega.Equal(jsonObj))
})
It("allows sort by random", func() {
newObj := goObj
newObj.Sort = "random"
gomega.Expect(newObj.OrderBy()).To(gomega.Equal("random() asc"))
})
})

View File

@ -43,6 +43,7 @@ var fieldMap = map[string]*mappedField{
"lastplayed": {field: "annotation.play_date"},
"playcount": {field: "COALESCE(annotation.play_count, 0)", order: "annotation.play_count"},
"rating": {field: "COALESCE(annotation.rating, 0)", order: "annotation.rating"},
"random": {field: "-", order: "random()"},
}
type mappedField struct {