]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Remove arbitrary page navigation for game_index.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 22 Feb 2015 21:27:55 +0000 (16:27 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 22 Feb 2015 21:27:55 +0000 (16:27 -0500)
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
xonstat/views/game.py

index fc96277480a0ec6557607e015ba05d1015e8b729..c74071b47c83acd4ce62c7e1cab4e57fc1810d40 100644 (file)
@@ -58,7 +58,7 @@ Game Index
         </tr>
       </thead>
       <tbody>
-      % for rg in recent_games.items:
+      % for rg in recent_games:
         <tr>
           <td class="tdcenter"><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
           <td class="tdcenter"><span alt="${rg.game_type_cd}" class="sprite sprite-${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
@@ -78,6 +78,14 @@ Game Index
   </div> <!-- /span12 -->
 </div> <!-- /row -->
 
-<!-- navigation links -->
-${navlinks("game_index", recent_games.page, recent_games.last_page, search_query=query)}
+<div class="row">
+  <div class="span12 text-center">
+    <ul class="pagination">
+      <li>
+        <a  href="${request.route_url('game_index', _query=query)}" name="Next Page">Next <i class="glyphicon glyphicon-arrow-right"></i></a>
+      </li>
+    </ul>
+  </div>
+</div>
+
 % endif
index aace99c48f662ef5f56278d60353e333765e82c3..b3d6038b5ac358c0704b4332e57a5172d7ad4886 100644 (file)
@@ -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,