]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Show player elo on the player info page.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 10 Mar 2012 13:00:18 +0000 (08:00 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 10 Mar 2012 13:00:18 +0000 (08:00 -0500)
xonstat/templates/player_info.mako
xonstat/views/player.py

index 528e736b5e29583e625e405011b4dd31a12be2e0..befb2d3d5366266d69e36faeb94bf7a0088608aa 100755 (executable)
@@ -17,14 +17,22 @@ Player Information
 
 % else:
 <div class="row">
-  <div class="span5">
+  <div class="span8">
     <h2>${player.nick_html_colors()|n}</h2>
     <p>
-       Member Since: ${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} <br />
-       Last Seen: ${recent_games[0][1].fuzzy_date()} <br />
-       Playing Time: ${game_stats['total_alivetime']} <br />
-       Games Played: ${game_stats['total_games_played']} <br />
-       Average Rank: ${game_stats['avg_rank']} <br />
+       Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
+       Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
+       Playing Time: <small>${game_stats['total_alivetime']} </small><br />
+       Games Played: <small>${game_stats['total_games_played']} </small><br />
+       Average Rank: <small>${game_stats['avg_rank']} </small><br />
+       % if elos_display is not None and len(elos_display) > 0:
+       Elo:
+          <small>${', '.join(elos_display)} </small>
+          <br />
+          %if '*' in ', '.join(elos_display):
+              <small><i>*preliminary Elo</i></small>
+          %endif
+      % endif
     </p>
   </div>
 </div>
index 5e82da74a8b0b7af3ce673d6f9ad9d10963def17..7fcfd62bdcc2414609f1713f6715873f1b5a99a3 100755 (executable)
@@ -53,11 +53,25 @@ def player_info(request):
     player_id = int(request.matchdict['id'])\r
     if player_id <= 2:\r
         player_id = -1;\r
-        \r
+\r
     try:\r
         player = DBSession.query(Player).filter_by(player_id=player_id).\\r
                 filter(Player.active_ind == True).one()\r
 \r
+        elos = DBSession.query(PlayerElo).filter_by(player_id=player_id).\\r
+                filter(PlayerElo.game_type_cd.in_(['ctf','duel','dm'])).\\r
+                order_by(PlayerElo.elo.desc()).all()\r
+\r
+        elos_display = []\r
+        for elo in elos:\r
+            if elo.games > 32:\r
+                str = "{0} ({1})"\r
+            else:\r
+                str = "{0}* ({1})"\r
+\r
+            elos_display.append(str.format(round(elo.elo, 3),\r
+                elo.game_type_cd))\r
+\r
         weapon_stats = DBSession.query("descr", "weapon_cd", "actual_total", \r
                 "max_total", "hit_total", "fired_total", "frags_total").\\r
                 from_statement(\r
@@ -118,11 +132,13 @@ def player_info(request):
 \r
     except Exception as e:\r
         player = None\r
+        elos_display = None\r
         weapon_stats = None\r
         game_stats = None\r
         recent_games = None\r
 \r
     return {'player':player, \r
+            'elos_display':elos_display,\r
             'recent_games':recent_games,\r
             'weapon_stats':weapon_stats,\r
             'game_stats':game_stats}\r