]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Initial checkin of tabs for the player_info view.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 20 Sep 2012 02:51:53 +0000 (22:51 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 20 Sep 2012 02:51:53 +0000 (22:51 -0400)
Underneath the player's nick will be a tabbed list of game types,
starting with "overall." Within each of these tabs will be stats
pertaining to only that game type. This allows players to view
fine-grained details about their playing history.

Note that this commit does not style the table much. This is mainly
to ensure that all of the content is being fetched properly.

xonstat/templates/player_info.mako
xonstat/views/player.py

index 4b9485838f39bb985e5e6f6748ebe49f58e07ee5..9787db8e32a04be1e388f8a36de4919da7f8eb7e 100644 (file)
@@ -10,9 +10,18 @@ ${nav.nav('players')}
     % if player is not None:
       <script src="/static/js/jquery-1.7.1.min.js"></script>
       <script src="/static/js/jquery.flot.min.js"></script>
+      <script src="/static/js/bootstrap-tab.js"></script>
       <script type="text/javascript">
       $(function () {
+        $('#gbtab').click(function(e) {
+            e.preventDefault();
+            $(this).tab('show');
+        })
+      })
+      </script>
 
+      <script type="text/javascript">
+      $(function () {
           // plot the accuracy graph
           function plot_acc_graph(data) {
               var games = new Array();
@@ -183,45 +192,49 @@ Player Information
 </div>
 
 <div class="row">
-  <div class="span6">
-    <p>
-      Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
+  <div class="tabbable tabs-right">
+      <ul id="gbtab" class="nav nav-tabs">
+      % for g in games_played:
+        <li><a href="#tab-${g.game_type_cd}" data-toggle="tab">${g.game_type_cd} (${g.games})</a></li>
+      % endfor
+      </ul>
 
-      Last Seen: <small><span class="abstime" data-epoch="${recent_games[0][1].epoch()}" title="${recent_games[0][1].create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${recent_games[0][1].fuzzy_date()}</span> </small><br />
+      <div class="tab-content">
+      % for g in games_played:
+        <div class="tab-pane fade in 
+        % if g.game_type_cd == 'overall':
+          active
+        % endif
+        " id="tab-${g.game_type_cd}">
+          <div class="span5">
+            % if g.game_type_cd in overall_stats:
+            Last Played: ${overall_stats[g.game_type_cd].last_played} <br />
+            % endif
 
-      Playing Time: <small>${total_stats['alivetime']} </small><br />
+            Games Played: ${g.games} <br />
 
-      <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in games_breakdown]) %>
-      Games Played: <small>${total_games} (${games_breakdown_str})</small><br />
+            % if g.game_type_cd in fav_maps:
+            Favorite Map: ${fav_maps[g.game_type_cd].map_name} <br />
+            % endif
 
-      % if fav_map is not None:
-      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>
-  <div class="span6">
-    <p>
-       % if total_games > 0 and total_stats['wins'] is not None:
-       Win Percentage: <small>${round(float(total_stats['wins'])/total_games * 100, 2)}% (${total_stats['wins']} wins, ${total_games - total_stats['wins']} losses) </small><br />
-       % endif
-
-       % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
-       Kill Ratio: <small>${round(float(total_stats['kills'])/total_stats['deaths'], 3)} (${total_stats['kills']} kills, ${total_stats['deaths']} deaths) </small><br />
-       % endif
-
-       % 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><br />
-          %endif
-      % endif
-
-      % if ranks_display != '':
-      Ranks: <small>${ranks_display}</small><br />
-      % endif
-    </p>
+            Win Percentage: ${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br />
+
+            % if g.game_type_cd in overall_stats:
+            Kill Ratio: ${round(overall_stats[g.game_type_cd].k_d_ratio,2)} (${overall_stats[g.game_type_cd].total_kills} kills, ${overall_stats[g.game_type_cd].total_deaths} deaths) <br />
+            % endif
+
+            % if g.game_type_cd in elos:
+            Elo: ${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br />
+            % endif
+
+            % if g.game_type_cd in ranks:
+            Rank: ${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} <br />
+            % endif
+
+          </div>
+        </div>
+      % endfor
+      </div>
   </div>
 </div>
 
index b33e93140ef11ab9d93c11eb53bb68bfb40790fd..7d51a1ddb32e5db786e1eaf293ee04d8aa4dd9b7 100644 (file)
@@ -102,13 +102,13 @@ def get_games_played(player_id):
         overall_games += games
         overall_wins += row.wins
         overall_losses += row.losses
-        win_pct = float(row.wins)/games
+        win_pct = float(row.wins)/games * 100
 
         games_played.append(GamesPlayed(row.game_type_cd, games, row.wins,
             row.losses, win_pct))
 
     try:
-        overall_win_pct = float(overall_wins)/overall_games
+        overall_win_pct = float(overall_wins)/overall_games * 100
     except:
         overall_win_pct = 0.0
 
@@ -669,63 +669,7 @@ def player_info(request):
     """
     Provides detailed information on a specific player
     """
-    player_info = player_info_data(request)
-
-    player         = player_info['player']
-    games_played   = player_info['games_played']
-    overall_stats  = player_info['overall_stats']
-    fav_maps       = player_info['fav_maps']
-    elos           = player_info['elos']
-    ranks          = player_info['ranks']
-    recent_games   = player_info['recent_games']
-    recent_weapons = player_info['recent_weapons']
-
-    # holds all of the tab content data
-    stat_strings = {}
-    for g in games_played:
-        stat_strings[g.game_type_cd] = []
-
-    # last seen, playing time
-    for k,v in overall_stats.iteritems():
-        stat_strings[k].append({'Last Played':v.last_played})
-        stat_strings[k].\
-                append({'Playing Time':v.total_playing_time})
-
-    # games played, win ratio
-    for g in games_played:
-        stat_strings[g.game_type_cd].append({'Games Played':g.games})
-        stat_strings[g.game_type_cd].\
-                append({'Win Pct':'{0} ({1} wins, {2} losses'.\
-                format(g.win_pct, g.wins, g.losses)})
-
-    # kill ratio
-    for k,v in overall_stats.iteritems():
-        stat_strings[k].\
-                append({'Kill Ratio':'{0} ({1} kills, {2} deaths)'.\
-                format(v.k_d_ratio, v.total_kills, v.total_deaths)})
-
-    # favorite maps
-    for k,v in fav_maps.iteritems():
-        stat_strings[k].append({'Favorite Map':v.map_name})
-
-    # elos
-    for k,v in elos.iteritems():
-        try:
-            stat_strings[k].append({'Elo':v.elo})
-        except:
-            pass
-
-    # ranks
-    for k,v in ranks.iteritems():
-        try:
-            stat_strings[k].append({'Rank':'{0} of {1}'.\
-                    format(v.rank, v.max_rank)})
-        except:
-            pass
-
-    print stat_strings
-
-    return player_info
+    return player_info_data(request)
 
 
 def player_info_json(request):