mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
Fix getSongsByGenre + remove some useless DISTINCTs
This commit is contained in:
parent
09d48fdb2e
commit
30734fe9ab
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2013-2022 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2013-2023 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -84,7 +84,7 @@ def album_list():
|
||||
},
|
||||
)
|
||||
elif ltype == "newest":
|
||||
query = query.order_by(Folder.created.desc()).distinct()
|
||||
query = query.order_by(Folder.created.desc())
|
||||
elif ltype == "highest":
|
||||
query = query.join(RatingFolder, JOIN.LEFT_OUTER).order_by(
|
||||
fn.avg(RatingFolder.rating).desc()
|
||||
@ -98,7 +98,7 @@ def album_list():
|
||||
elif ltype == "starred":
|
||||
query = query.join(StarredFolder).where(StarredFolder.user == request.user)
|
||||
elif ltype == "alphabeticalByName":
|
||||
query = query.order_by(Folder.name).distinct()
|
||||
query = query.order_by(Folder.name)
|
||||
elif ltype == "alphabeticalByArtist":
|
||||
parent = Folder.alias()
|
||||
query = query.join(parent).order_by(parent.name, Folder.name)
|
||||
@ -212,7 +212,7 @@ def songs_by_genre():
|
||||
{
|
||||
"song": [
|
||||
t.as_subsonic_child(request.user, request.client)
|
||||
for t in query.limit(count, offset)
|
||||
for t in query.limit(count).offset(offset)
|
||||
]
|
||||
},
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of Supysonic.
|
||||
# Supysonic is a Python implementation of the Subsonic server API.
|
||||
#
|
||||
# Copyright (C) 2017-2022 Alban 'spl0k' Féron
|
||||
# Copyright (C) 2017-2023 Alban 'spl0k' Féron
|
||||
#
|
||||
# Distributed under terms of the GNU AGPLv3 license.
|
||||
|
||||
@ -267,6 +267,26 @@ class AlbumSongsTestCase(ApiTestBase):
|
||||
self._make_request("getStarred2", tag="starred2")
|
||||
self._make_request("getStarred2", {"musicFolderId": 1}, tag="starred2")
|
||||
|
||||
def test_get_songs_by_genre(self):
|
||||
self._make_request("getSongsByGenre", error=10)
|
||||
self._make_request(
|
||||
"getSongsByGenre", {"genre": "genre", "musicFolderId": "idid"}, error=0
|
||||
)
|
||||
self._make_request(
|
||||
"getSongsByGenre", {"genre": "genre", "musicFolderId": 1234567890}, error=70
|
||||
)
|
||||
self._make_request(
|
||||
"getSongsByGenre", {"genre": "genre", "count": "three"}, error=0
|
||||
)
|
||||
self._make_request(
|
||||
"getSongsByGenre", {"genre": "genre", "offset": "four"}, error=0
|
||||
)
|
||||
|
||||
rv, child = self._make_request(
|
||||
"getSongsByGenre", {"genre": "Lampshade"}, tag="songsByGenre"
|
||||
)
|
||||
self.assertEqual(len(child), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user