1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Fix int vs float arithmetic

This commit is contained in:
spl0k 2013-06-13 19:06:04 +02:00
parent b4e3b22089
commit 861ab1c39a

View File

@ -1,7 +1,7 @@
# coding: utf-8 # coding: utf-8
from flask import request from flask import request
from sqlalchemy import desc, func from sqlalchemy import desc, func, cast, Float
from sqlalchemy.orm import aliased from sqlalchemy.orm import aliased
import random import random
import uuid import uuid
@ -64,7 +64,7 @@ def album_list():
elif ltype == 'highest': elif ltype == 'highest':
return request.error_formatter(0, 'Not implemented') return request.error_formatter(0, 'Not implemented')
elif ltype == 'frequent': elif ltype == 'frequent':
query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.sum(Track.play_count) / func.count())) query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(cast(func.sum(Track.play_count), Float) / func.count()))
elif ltype == 'recent': elif ltype == 'recent':
query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play))) query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play)))
elif ltype == 'starred': elif ltype == 'starred':
@ -103,7 +103,7 @@ def album_list_id3():
elif ltype == 'newest': elif ltype == 'newest':
query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.min(Track.created))) query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.min(Track.created)))
elif ltype == 'frequent': elif ltype == 'frequent':
query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.sum(Track.play_count) / func.count())) query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(cast(func.sum(Track.play_count), Float) / func.count()))
elif ltype == 'recent': elif ltype == 'recent':
query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.max(Track.last_play))) query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.max(Track.last_play)))
elif ltype == 'starred': elif ltype == 'starred':