1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Don't distinct random queries

Fixes #89
This commit is contained in:
spl0k 2018-03-12 21:06:57 +01:00
parent e5d9050fa7
commit b4a9a21671

View File

@ -7,7 +7,6 @@
# #
# Distributed under terms of the GNU AGPLv3 license. # Distributed under terms of the GNU AGPLv3 license.
import random
import uuid import uuid
from datetime import timedelta from datetime import timedelta
@ -45,7 +44,7 @@ def rand_songs():
query = query.filter(lambda t: t.root_folder.id == fid) query = query.filter(lambda t: t.root_folder.id == fid)
return request.formatter('randomSongs', dict( return request.formatter('randomSongs', dict(
song = [ t.as_subsonic_child(request.user, request.client) for t in query.random(size) ] song = [ t.as_subsonic_child(request.user, request.client) for t in query.without_distinct().random(size) ]
)) ))
@api.route('/getAlbumList.view', methods = [ 'GET', 'POST' ]) @api.route('/getAlbumList.view', methods = [ 'GET', 'POST' ])
@ -59,7 +58,7 @@ def album_list():
query = select(t.folder for t in Track) query = select(t.folder for t in Track)
if ltype == 'random': if ltype == 'random':
return request.formatter('albumList', dict( return request.formatter('albumList', dict(
album = [ a.as_subsonic_child(request.user) for a in query.random(size) ] album = [ a.as_subsonic_child(request.user) for a in query.without_distinct().random(size) ]
)) ))
elif ltype == 'newest': elif ltype == 'newest':
query = query.order_by(desc(Folder.created)) query = query.order_by(desc(Folder.created))