]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Fixed bug in "total wins" query - NOTE: other queries (e.g. duel wins) are still...
authorJan D. Behrens <zykure@web.de>
Tue, 28 Aug 2012 16:49:02 +0000 (18:49 +0200)
committerJan D. Behrens <zykure@web.de>
Tue, 28 Aug 2012 16:49:02 +0000 (18:49 +0200)
xonstat/views/player.py

index 0bc24b90e42448dea945f10b4625eff644f2c996..a1ff71919612d4c1e2051e0c4586ba3cafe7150f 100644 (file)
@@ -138,12 +138,22 @@ def _get_total_stats(player_id):
             filter(PlayerGameStat.create_dt > one_month_ago).\
             one()
 
-    (total_stats['wins'],) = DBSession.query(
-            func.count("*")).\
-            filter(Game.game_id == PlayerGameStat.game_id).\
-            filter(PlayerGameStat.player_id == player_id).\
-            filter(Game.winner == PlayerGameStat.team or PlayerGameStat.rank == 1).\
-            one()
+    (total_stats['wins'],) = DBSession.\
+            query("total_wins").\
+            from_statement(
+                "select count(*) total_wins "
+                "from games g, player_game_stats pgs "
+                "where g.game_id = pgs.game_id "
+                "and player_id=:player_id "
+                "and (g.winner = pgs.team or pgs.rank = 1)"
+            ).params(player_id=player_id).one()
+
+#    (total_stats['wins'],) = DBSession.query(
+#            func.count("*")).\
+#            filter(Game.game_id == PlayerGameStat.game_id).\
+#            filter(PlayerGameStat.player_id == player_id).\
+#            filter(Game.winner == PlayerGameStat.team or PlayerGameStat.rank == 1).\
+#            one()
 
     (total_stats['duel_wins'],) = DBSession.query(
             func.count("*")).\