Recursively refresh playlist tracks within smart playlist rules (#3018)
* Recursively refresh playlists within smart playlist rules Signed-off-by: reillymc <reilly@mackenzie-cree.net> * Clean up recursive smart playlist functions Signed-off-by: reillymc <reilly@mackenzie-cree.net> * Add smart playlist refresh timeout config and tests for nested track refetching Signed-off-by: reillymc <reilly@mackenzie-cree.net> * Change SmartPlaylistRefreshTimeout to SmartPlaylistRefreshDelay, increase default value * Revert `smartPlaylistRefreshDelay` default to 5 seconds --------- Signed-off-by: reillymc <reilly@mackenzie-cree.net> Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
committed by
GitHub
parent
180035c1e3
commit
d683688b0e
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
@@ -89,4 +90,94 @@ var _ = Describe("Criteria", func() {
|
||||
gomega.Expect(newObj.OrderBy()).To(gomega.Equal("random() asc"))
|
||||
})
|
||||
|
||||
It("extracts all child smart playlist IDs from All expression criteria", func() {
|
||||
topLevelInPlaylistID := uuid.NewString()
|
||||
topLevelNotInPlaylistID := uuid.NewString()
|
||||
|
||||
nestedAnyInPlaylistID := uuid.NewString()
|
||||
nestedAnyNotInPlaylistID := uuid.NewString()
|
||||
|
||||
nestedAllInPlaylistID := uuid.NewString()
|
||||
nestedAllNotInPlaylistID := uuid.NewString()
|
||||
|
||||
goObj := Criteria{
|
||||
Expression: All{
|
||||
InPlaylist{"id": topLevelInPlaylistID},
|
||||
NotInPlaylist{"id": topLevelNotInPlaylistID},
|
||||
Any{
|
||||
InPlaylist{"id": nestedAnyInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAnyNotInPlaylistID},
|
||||
},
|
||||
All{
|
||||
InPlaylist{"id": nestedAllInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAllNotInPlaylistID},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ids := goObj.ChildPlaylistIds()
|
||||
|
||||
gomega.Expect(ids).To(gomega.ConsistOf(topLevelInPlaylistID, topLevelNotInPlaylistID, nestedAnyInPlaylistID, nestedAnyNotInPlaylistID, nestedAllInPlaylistID, nestedAllNotInPlaylistID))
|
||||
})
|
||||
|
||||
It("extracts all child smart playlist IDs from Any expression criteria", func() {
|
||||
topLevelInPlaylistID := uuid.NewString()
|
||||
topLevelNotInPlaylistID := uuid.NewString()
|
||||
|
||||
nestedAnyInPlaylistID := uuid.NewString()
|
||||
nestedAnyNotInPlaylistID := uuid.NewString()
|
||||
|
||||
nestedAllInPlaylistID := uuid.NewString()
|
||||
nestedAllNotInPlaylistID := uuid.NewString()
|
||||
|
||||
goObj := Criteria{
|
||||
Expression: Any{
|
||||
InPlaylist{"id": topLevelInPlaylistID},
|
||||
NotInPlaylist{"id": topLevelNotInPlaylistID},
|
||||
Any{
|
||||
InPlaylist{"id": nestedAnyInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAnyNotInPlaylistID},
|
||||
},
|
||||
All{
|
||||
InPlaylist{"id": nestedAllInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAllNotInPlaylistID},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ids := goObj.ChildPlaylistIds()
|
||||
|
||||
gomega.Expect(ids).To(gomega.ConsistOf(topLevelInPlaylistID, topLevelNotInPlaylistID, nestedAnyInPlaylistID, nestedAnyNotInPlaylistID, nestedAllInPlaylistID, nestedAllNotInPlaylistID))
|
||||
})
|
||||
|
||||
It("extracts child smart playlist IDs from deeply nested expression", func() {
|
||||
nestedAnyInPlaylistID := uuid.NewString()
|
||||
nestedAnyNotInPlaylistID := uuid.NewString()
|
||||
|
||||
nestedAllInPlaylistID := uuid.NewString()
|
||||
nestedAllNotInPlaylistID := uuid.NewString()
|
||||
|
||||
goObj := Criteria{
|
||||
Expression: Any{
|
||||
Any{
|
||||
All{
|
||||
Any{
|
||||
InPlaylist{"id": nestedAnyInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAnyNotInPlaylistID},
|
||||
Any{
|
||||
All{
|
||||
InPlaylist{"id": nestedAllInPlaylistID},
|
||||
NotInPlaylist{"id": nestedAllNotInPlaylistID},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ids := goObj.ChildPlaylistIds()
|
||||
|
||||
gomega.Expect(ids).To(gomega.ConsistOf(nestedAnyInPlaylistID, nestedAnyNotInPlaylistID, nestedAllInPlaylistID, nestedAllNotInPlaylistID))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user