Skip to content

Commit

Permalink
Add "random" sort option for Smart Playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Feb 9, 2022
1 parent e966d94 commit 50ff8bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions model/criteria/criteria_test.go
Expand Up @@ -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"))
})

})
1 change: 1 addition & 0 deletions model/criteria/fields.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 50ff8bc

Please sign in to comment.