1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06: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.
import random
import uuid
from datetime import timedelta
@ -45,7 +44,7 @@ def rand_songs():
query = query.filter(lambda t: t.root_folder.id == fid)
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' ])
@ -59,7 +58,7 @@ def album_list():
query = select(t.folder for t in Track)
if ltype == 'random':
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':
query = query.order_by(desc(Folder.created))