Skip to content

Commit

Permalink
Include never played songs in the "not in the last" operator
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Oct 24, 2021
1 parent 2b57b98 commit 9473536
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion persistence/sql_smartplaylist.go
Expand Up @@ -183,7 +183,10 @@ func (r dateRule) inTheLast(invert bool) (Sqlizer, error) {
}
period := time.Now().Add(time.Duration(-24*v) * time.Hour)
if invert {
return Lt{r.Field: period}, nil
return Or{
Lt{r.Field: period},
Eq{r.Field: nil},
}, nil
}
return Gt{r.Field: period}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion persistence/sql_smartplaylist_test.go
Expand Up @@ -135,7 +135,7 @@ var _ = Describe("smartPlaylist", func() {
Expect(args).To(ConsistOf(BeTemporally("~", expectedValue, delta)))
},
Entry("in the last", "in the last", "lastPlayed > ?", date.Add(-90*24*time.Hour)),
Entry("not in the last", "not in the last", "lastPlayed < ?", date.Add(-90*24*time.Hour)),
Entry("not in the last", "not in the last", "(lastPlayed < ? OR lastPlayed IS NULL)", date.Add(-90*24*time.Hour)),
)

It("accepts string as the 'in the last' operator value", func() {
Expand Down

0 comments on commit 9473536

Please sign in to comment.