From b4a9a21671578bd36a78db0c7290461f04065210 Mon Sep 17 00:00:00 2001 From: spl0k Date: Mon, 12 Mar 2018 21:06:57 +0100 Subject: [PATCH] Don't distinct random queries Fixes #89 --- supysonic/api/albums_songs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 643494f..b5abb9a 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -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))