From 9f55e7143ba65cdd40ddc95b6e33262a1fd2c1a2 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 22 Feb 2015 16:27:55 -0500 Subject: [PATCH] Remove arbitrary page navigation for game_index. This gives us a HUGE performance boost b/c it avoids requiring a full select count(*) on the games table. For now the navigation will be forward only. --- xonstat/templates/game_finder.mako | 14 +++++++++++--- xonstat/views/game.py | 23 ++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/xonstat/templates/game_finder.mako b/xonstat/templates/game_finder.mako index fc96277..c74071b 100644 --- a/xonstat/templates/game_finder.mako +++ b/xonstat/templates/game_finder.mako @@ -58,7 +58,7 @@ Game Index - % for rg in recent_games.items: + % for rg in recent_games: view @@ -78,6 +78,14 @@ Game Index - -${navlinks("game_index", recent_games.page, recent_games.last_page, search_query=query)} +
+
+ +
+
+ % endif diff --git a/xonstat/views/game.py b/xonstat/views/game.py index aace99c..b3d6038 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -177,7 +177,7 @@ def game_finder_data(request): query = {} server_id, map_id, player_id = None, None, None - range_start, range_end, game_type_cd = None, None, None + game_type_cd, start_game_id, end_game_id = None, None, None game_type_descr = None # these become WHERE clauses when present @@ -193,13 +193,13 @@ def game_finder_data(request): player_id = request.params['player_id'] query['player_id'] = player_id - if request.params.has_key('range_start'): - range_start = request.params['range_start'] - query['range_start'] = range_start + if request.params.has_key('start_game_id'): + start_game_id = request.params['start_game_id'] + query['start_game_id'] = start_game_id - if request.params.has_key('range_end'): - range_end = request.params['range_end'] - query['range_end'] = range_end + if request.params.has_key('end_game_id'): + end_game_id = request.params['end_game_id'] + query['end_game_id'] = end_game_id if request.params.has_key('type'): game_type_cd = request.params['type'] @@ -212,11 +212,12 @@ def game_finder_data(request): game_type_cd = None rgs_q = recent_games_q(server_id=server_id, map_id=map_id, - player_id=player_id, game_type_cd=game_type_cd) + player_id=player_id, game_type_cd=game_type_cd, + start_game_id=start_game_id, end_game_id=end_game_id) - recent_games = Page(rgs_q, current_page, url=page_url) - - recent_games.items = [RecentGame(row) for row in recent_games.items] + recent_games = [RecentGame(row) for row in rgs_q.limit(20).all()] + + query['start_game_id'] = recent_games[-1].game_id + 1 return { 'recent_games':recent_games, -- 2.39.2