Optimize refresh events for scrobble endpoint

This commit is contained in:
Deluan
2021-06-16 10:23:34 -04:00
parent fb7229a53e
commit 86271f0412
3 changed files with 15 additions and 5 deletions
+3
View File
@@ -53,6 +53,9 @@ func (rr *RefreshResource) With(resource string, ids ...string) *RefreshResource
if rr.resources == nil {
rr.resources = make(map[string][]string)
}
if len(ids) == 0 {
rr.resources[resource] = append(rr.resources[resource], Any)
}
for i := range ids {
rr.resources[resource] = append(rr.resources[resource], ids[i])
}
+2 -2
View File
@@ -37,8 +37,8 @@ var _ = Describe("Events", func() {
data := rr.Data(rr)
Expect(data).To(Equal(`{"album":["al-1","al-2","al-3"],"artist":["ar-1","ar-2"],"song":["sg-1","sg-2"]}`))
})
It("should send a * for when Any is used as id", func() {
rr.With("album", Any)
It("should send a * when no ids are specified", func() {
rr.With("album")
data := rr.Data(rr)
Expect(data).To(Equal(`{"album":["*"]}`))
})