From f903dc9306191e368f308bb286c161aefb96d721 Mon Sep 17 00:00:00 2001 From: lxnay Date: Sat, 1 Nov 2008 17:34:42 +0000 Subject: [PATCH] Entropy/DistributionUGCInterface: - get_user_score_ranking(): fix sql query - get_user_votes_count(): return int, not float git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2612 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/entropy.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libraries/entropy.py b/libraries/entropy.py index 5b1df7a3e..6250136ed 100644 --- a/libraries/entropy.py +++ b/libraries/entropy.py @@ -17911,10 +17911,8 @@ class DistributionUGCInterface(RemoteDbSkelInterface): def get_user_score_ranking(self, userid): self.check_connection() - self.execute_script(""" - SET @row = 0; - SELECT Row, col_a FROM (SELECT @row := @row + 1 AS Row, userid AS col_a FROM entropy_user_scores ORDER BY score DESC) As derived1 WHERE col_a = %s - """, (userid,)) + self.execute_query('SET @row = 0') + self.execute_query('SELECT Row, col_a FROM (SELECT @row := @row + 1 AS Row, userid AS col_a FROM entropy_user_scores ORDER BY score DESC) As derived1 WHERE col_a = %s', (userid,)) data = self.fetchone() if isinstance(data,dict): if data.get('Row'): return int(data['Row']) @@ -17975,7 +17973,7 @@ class DistributionUGCInterface(RemoteDbSkelInterface): self.execute_query('SELECT avg(`vote`) as vote_avg FROM entropy_votes WHERE `userid` = %s', (userid,)) data = self.fetchone() if isinstance(data,dict): - if data['vote_avg']: return float(data['vote_avg']) + if data['vote_avg']: return round(float(data['vote_avg']),2) return 0.0 def get_user_docs(self, userid): @@ -18027,7 +18025,7 @@ class DistributionUGCInterface(RemoteDbSkelInterface): self.execute_query('SELECT count(`idvote`) as votes FROM entropy_votes WHERE `userid` = %s', (userid,)) data = self.fetchone() if isinstance(data,dict): - if data['votes']: return float(data['votes']) + if data['votes']: return int(data['votes']) return 0 def get_user_stats(self, userid):