Resolve "Pagination of results in genres in Subsonic API does not work"

This commit is contained in:
Eliot Berriot 2019-10-28 08:58:32 +01:00
parent ae0f7588e4
commit 69795b5ca2
3 changed files with 25 additions and 1 deletions

View file

@ -351,6 +351,12 @@ class SubsonicViewSet(viewsets.GenericViewSet):
)
)
queryset = queryset.playable_by(actor)
try:
offset = int(data.get("offset", 0))
except (TypeError, ValueError):
offset = 0
try:
size = int(
data["count"]
@ -369,7 +375,7 @@ class SubsonicViewSet(viewsets.GenericViewSet):
)
.prefetch_related("uploads")
.distinct()
.order_by("-creation_date")[:size]
.order_by("-creation_date")[offset : offset + size]
)
data = {
"songsByGenre": {