]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Use the GIN index wherever possible.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 25 Dec 2014 03:32:17 +0000 (22:32 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 25 Dec 2014 03:32:17 +0000 (22:32 -0500)
xonstat/views/helpers.py
xonstat/views/player.py

index 8a10a48b733d8602ea3f5fd6fb72203021eaae23..d8b3211e1c231b7c806d799c69bdfc34e8c9e548 100644 (file)
@@ -116,11 +116,13 @@ def recent_games_q(server_id=None, map_id=None, player_id=None,
     if player_id is not None:
         if force_player_id:
             recent_games_q = recent_games_q.\
-                filter(PlayerGameStat.player_id==player_id)
+                filter(PlayerGameStat.player_id==player_id).\
+                filter(Game.players.contains([player_id]))
         else:
             recent_games_q = recent_games_q.\
                 filter(PlayerGameStat.scoreboardpos==1).\
                 filter(Game.game_id==pgstat_alias.game_id).\
+                filter(Game.players.contains([player_id])).\
                 filter(pgstat_alias.player_id==player_id)
     else:
         recent_games_q = recent_games_q.\
index 479ea1eb01f49576051febdbd7a177439aa8b68e..c3e5120984680ce361713c84b1ebd125f4aa0f11 100644 (file)
@@ -89,7 +89,8 @@ def get_games_played(player_id):
                         "FROM   games g, "
                                "player_game_stats pgs "
                         "WHERE  g.game_id = pgs.game_id "
-                        "AND pgs.player_id = :player_id) win_loss "
+                        "AND pgs.player_id = :player_id "
+                        "AND g.players @> ARRAY[:player_id]) win_loss "
                 "GROUP  BY game_type_cd "
             ).params(player_id=player_id).all()
 
@@ -167,6 +168,7 @@ def get_overall_stats(player_id):
                        "player_game_stats pgs "
                 "WHERE  g.game_id = pgs.game_id "
                   "AND  g.game_type_cd = gt.game_type_cd "
+                  "AND  g.players @> ARRAY[:player_id] "
                   "AND  pgs.player_id = :player_id "
                 "GROUP  BY g.game_type_cd, game_type_descr "
                 "UNION "
@@ -289,6 +291,7 @@ def get_fav_maps(player_id, game_type_cd=None):
                                "maps m "
                         "WHERE  g.game_id = pgs.game_id "
                                "AND g.map_id = m.map_id "
+                               "AND g.players @> ARRAY[:player_id]"
                                "AND pgs.player_id = :player_id "
                         "GROUP  BY g.game_type_cd, "
                                   "m.map_id, "