From: Jan D. Behrens Date: Tue, 28 Aug 2012 16:49:02 +0000 (+0200) Subject: Fixed bug in "total wins" query - NOTE: other queries (e.g. duel wins) are still... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b32454b30219ec8f0354a58733e109f102299aa2;p=xonotic%2Fxonstat.git Fixed bug in "total wins" query - NOTE: other queries (e.g. duel wins) are still flawed! --- diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 0bc24b9..a1ff719 100644 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -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("*")).\