]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Change the query group by, return dict instead of Map.
authorAnt Zucaro <azucaro@gmail.com>
Mon, 18 Jun 2012 00:35:04 +0000 (20:35 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Mon, 18 Jun 2012 00:35:04 +0000 (20:35 -0400)
xonstat/templates/player_info.mako
xonstat/views/player.py

index f154463ecd66d9a65ebfdc63a7d99009d8cee26c..9c8376d0f156f93808fbcd4cd9e4f82ade98fe9d 100644 (file)
@@ -190,7 +190,7 @@ Player Information
       Games Played: <small>${total_games} (${games_breakdown_str})</small><br />
 
       % if fav_map is not None:
-      Favorite Map: <small><a href="${request.route_url('map_info', id=fav_map.map_id)}" title="view map info">${fav_map.name}</a></small><br />
+      Favorite Map: <small><a href="${request.route_url('map_info', id=fav_map['id'])}" title="view map info">${fav_map['name']}</a></small><br />
       % endif
     </p>
   </div>
index 9eaf218f20026eb89a567ba03450f88abd727920..211fe095238e0f2b644042d8ab5ce4c559807de6 100644 (file)
@@ -121,20 +121,24 @@ def _get_fav_map(player_id):
     as the map that he or she has played the most in the past 
     90 days.
 
-    Returns a map object.
+    Returns a dictionary with keys for the map's name and id.
     """
     # 90 day window
     back_then = datetime.datetime.utcnow() - datetime.timedelta(days=90)
 
-    fav_map = DBSession.query(Map).\
+    raw_fav_map = DBSession.query(Map.name, Map.map_id).\
             filter(Game.game_id == PlayerGameStat.game_id).\
             filter(Game.map_id == Map.map_id).\
             filter(PlayerGameStat.player_id == player_id).\
             filter(PlayerGameStat.create_dt > back_then).\
-            group_by(Map.map_id).\
+            group_by(Map.name, Map.map_id).\
             order_by(func.count().desc()).\
             limit(1).one()
 
+    fav_map = {}
+    fav_map['name'] = raw_fav_map[0]
+    fav_map['id'] = raw_fav_map[1]
+
     return fav_map