]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Add top_maps to main view and template.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 16 Jun 2011 10:53:15 +0000 (06:53 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 16 Jun 2011 10:53:15 +0000 (06:53 -0400)
xonstat/templates/main_index.mako
xonstat/views/main.py

index 0caccc17bcbe90fe09c220c196a569cb6a51f05c..12d5323e762cd1e9aff426802f47ba71e767b75a 100755 (executable)
@@ -43,3 +43,23 @@ Main Page - ${parent.title()}
 </tr>\r
 % endfor\r
 </table>\r
+\r
+<table>\r
+<tr>\r
+<th>Map</th>\r
+<th>Times Played</th>\r
+</tr>\r
+% for (map_id, name, count) in top_maps:\r
+<tr>\r
+<td>${name}</td>\r
+<td>${count}</td>\r
+</tr>\r
+% endfor\r
+\r
+% for i in range(10 - len(top_maps)):\r
+<tr>\r
+<td>-</td>\r
+<td>-</td>\r
+</tr>\r
+% endfor\r
+</table>\r
index 2e59f3f8e26176679eee798c03bd7e608e5e1e1e..811a1a626f68ae7fc2b75d33702c886f4f319c61 100755 (executable)
@@ -17,12 +17,21 @@ def main_index(request):
 
     # top servers by number of total players played
     top_servers = DBSession.query(Server.server_id, Server.name, 
-            func.count(Game.game_id)).\
+            func.count()).\
             filter(Game.server_id==Server.server_id).\
             order_by(func.count(Game.game_id)).\
             group_by(Server.server_id).\
             group_by(Server.name).all()[0:10]
 
+    # top maps by total times played
+    top_maps = DBSession.query(Map.map_id, Map.name, 
+            func.count(Game.game_id)).\
+            filter(Map.map_id==Game.game_id).\
+            order_by(func.count(Game.game_id)).\
+            group_by(Map.map_id).\
+            group_by(Map.name).all()[0:10]
+
     return {'top_players':top_players,
             'top_servers':top_servers,
+            'top_maps':top_maps,
             }