From 861ab1c39a15cd938a078277f0b6ad70ee71dbff Mon Sep 17 00:00:00 2001 From: spl0k Date: Thu, 13 Jun 2013 19:06:04 +0200 Subject: [PATCH] Fix int vs float arithmetic --- api/albums_songs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/albums_songs.py b/api/albums_songs.py index afcf487..99ef850 100755 --- a/api/albums_songs.py +++ b/api/albums_songs.py @@ -1,7 +1,7 @@ # coding: utf-8 from flask import request -from sqlalchemy import desc, func +from sqlalchemy import desc, func, cast, Float from sqlalchemy.orm import aliased import random import uuid @@ -64,7 +64,7 @@ def album_list(): elif ltype == 'highest': return request.error_formatter(0, 'Not implemented') 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': query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play))) elif ltype == 'starred': @@ -103,7 +103,7 @@ def album_list_id3(): elif ltype == 'newest': query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.min(Track.created))) 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': query = query.join(Track, Album.tracks).group_by(Album.id).order_by(desc(func.max(Track.last_play))) elif ltype == 'starred':