Sort randomly directly in SQLite

This commit is contained in:
Lucas Verney 2016-09-27 03:42:04 +02:00
parent 220c68f38b
commit 14c2ea65db
1 changed files with 2 additions and 3 deletions

View File

@ -181,9 +181,8 @@ def main(queue_length):
# Get all other songs coordinates and iterate randomly on them
closest_song = None
cur.execute("SELECT id, tempo1, tempo2, tempo3, amplitude, frequency, attack, filename FROM songs")
songs = random.shuffle([song for song in cur.fetchall()])
for tmp_song_data in songs:
cur.execute("SELECT id, tempo1, tempo2, tempo3, amplitude, frequency, attack, filename FROM songs ORDER BY RANDOM()")
for tmp_song_data in cur.fetchall():
if(tmp_song_data["filename"] == current_song_coords["filename"] or
tmp_song_data["filename"] in cached_distances_songs or
("file: %s" % (tmp_song_data["filename"],)) in client.playlist()):