Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julien Veyssier
funkwhale
Commits
03178455
Verified
Commit
03178455
authored
Jun 10, 2018
by
Eliot Berriot
Browse files
Fixed #295: broken pagination in Subsonic API
parent
4c81de92
Changes
3
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/subsonic/views.py
View file @
03178455
...
...
@@ -208,7 +208,9 @@ class SubsonicViewSet(viewsets.GenericViewSet):
methods
=
[
"get"
,
"post"
],
url_name
=
"get_album_list2"
,
url_path
=
"getAlbumList2"
)
def
get_album_list2
(
self
,
request
,
*
args
,
**
kwargs
):
queryset
=
music_models
.
Album
.
objects
.
with_tracks_count
()
queryset
=
music_models
.
Album
.
objects
.
with_tracks_count
().
order_by
(
"artist__name"
)
data
=
request
.
GET
or
request
.
POST
filterset
=
filters
.
AlbumList2FilterSet
(
data
,
queryset
=
queryset
)
queryset
=
filterset
.
qs
...
...
@@ -223,7 +225,7 @@ class SubsonicViewSet(viewsets.GenericViewSet):
size
=
50
size
=
min
(
size
,
500
)
queryset
=
queryset
[
offset
:
size
]
queryset
=
queryset
[
offset
:
offset
+
size
]
data
=
{
"albumList2"
:
{
"album"
:
serializers
.
get_album_list2_data
(
queryset
)}}
return
response
.
Response
(
data
)
...
...
@@ -283,7 +285,7 @@ class SubsonicViewSet(viewsets.GenericViewSet):
queryset
=
c
[
"queryset"
].
filter
(
utils
.
get_query
(
query
,
c
[
"search_fields"
])
)
queryset
=
queryset
[
offset
:
size
]
queryset
=
queryset
[
offset
:
offset
+
size
]
payload
[
"searchResult3"
][
c
[
"subsonic"
]]
=
c
[
"serializer"
](
queryset
)
return
response
.
Response
(
payload
)
...
...
api/tests/subsonic/test_views.py
View file @
03178455
...
...
@@ -217,6 +217,22 @@ def test_get_album_list2(f, db, logged_in_api_client, factories):
}
@
pytest
.
mark
.
parametrize
(
"f"
,
[
"xml"
,
"json"
])
def
test_get_album_list2_pagination
(
f
,
db
,
logged_in_api_client
,
factories
):
url
=
reverse
(
"api:subsonic-get-album-list2"
)
assert
url
.
endswith
(
"getAlbumList2"
)
is
True
album1
=
factories
[
"music.Album"
]()
factories
[
"music.Album"
]()
response
=
logged_in_api_client
.
get
(
url
,
{
"f"
:
f
,
"type"
:
"newest"
,
"size"
:
1
,
"offset"
:
1
}
)
assert
response
.
status_code
==
200
assert
response
.
data
==
{
"albumList2"
:
{
"album"
:
serializers
.
get_album_list2_data
([
album1
])}
}
@
pytest
.
mark
.
parametrize
(
"f"
,
[
"xml"
,
"json"
])
def
test_search3
(
f
,
db
,
logged_in_api_client
,
factories
):
url
=
reverse
(
"api:subsonic-search3"
)
...
...
changes/changelog.d/295.bugfix
0 → 100644
View file @
03178455
Fixed broken pagination in Subsonic API (#295)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment