]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Add rankings to the main page.
authorAnt Zucaro <azucaro@gmail.com>
Fri, 20 Jan 2012 02:56:25 +0000 (21:56 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Fri, 20 Jan 2012 02:56:25 +0000 (21:56 -0500)
xonstat/static/css/style.css
xonstat/static/js/default.js
xonstat/templates/main_index.mako
xonstat/views/main.py

index 2dde72c7d851f875e3cd94db69bf8894c2cceda5..8f50faab98e99bdbb797ba92097938839f47dda9 100755 (executable)
@@ -369,10 +369,10 @@ input[type=text]:hover, .textbox:hover { background-position:-128px -32px; }
 /* Content Specific */
 
 /*Tables */
-#top-players, #top-servers, #top-maps {
+#top-players, #top-servers, #top-maps, .rank-table{
     float: left;
     margin-bottom: 10px;
-    width:100%;
+    width: 290px;
 }
 #player-index-table, #server-index-table{
     width: 600px;
@@ -424,6 +424,10 @@ tr.even.blue {
     width: 150px;
 }
 
+.play-time{
+    width: 70px;
+}
+
 /* Containers */
 #filter {
        float:left;
@@ -496,3 +500,7 @@ tr.even.blue {
        color:#A4B7CA !important;
        text-decoration:underline;
 }
+.note {
+    font-size: 10px;
+       color:#6D8399;
+}
index af05cd4e6f2c44618668ebbd07626d4685fc657a..f0096e8b1dbc9b8d48f8a51b86da1b9c60b30a79 100644 (file)
@@ -60,7 +60,7 @@ function init_datatables() {
                $("#recent-games").dataTable({
                        "bPaginate": false,
                        "bLengthChange": false,
-                       "bFilter": true,
+                       "bFilter": false,
                        "bSort": true,
                        "bInfo": false,
                        "bAutoWidth": false,
index 132a943cd7705ce60a8a3b0d0c5385f2f8a23d35..397d1c9b90a5cd18c414e1169b6ac8e1a94dcaa0 100755 (executable)
 Main Page - ${parent.title()}\r
 </%block>\r
 \r
-\r
-##### RECENT GAMES #####\r
-<h2>Recent Games</h2>\r
-<table id="recent-games">\r
+##### DUEL RANKS #####\r
+<div class="table_block">\r
+<h2>Duel Ranks</h2>\r
+<table class="rank-table">\r
        <thead>\r
                <tr>\r
-                       <th>Game #</th>\r
-                       <th>Type</th>\r
-                       <th>Server</th>\r
-                       <th>Map</th>\r
-                       <th>Time</th>\r
-                       <th>Winner</th>\r
+                       <th>#</th>\r
+                       <th>Nick</th>\r
+                       <th>Elo</th>\r
                </tr>\r
        </thead>\r
        <tbody>\r
-       % for (game, server, map, pgstat) in recent_games:\r
-               % if game != '-':\r
+       <% i = 1 %>\r
+       % for (player_id, nick, elo) in duel_ranks:\r
                <tr>\r
-                       <td><a href="${request.route_url('game_info', id=game.game_id)}" title="View detailed information about this game">${game.game_id}</a></td>\r
-                       <td class="gt_icon"><img title="${game.game_type_cd}" src="/static/images/icons/24x24/${game.game_type_cd}.png" alt="${game.game_type_cd}" /></td>\r
-                       <td><a href="${request.route_url('server_info', id=server.server_id)}" title="Go to the detail page for this server">${server.name}</a></td>\r
-                       <td><a href="${request.route_url('map_info', id=map.map_id)}" title="Go to the map detail page for this map">${map.name}</a></td>\r
-                       <td>${game.start_dt.strftime('%m/%d/%Y %H:%M')}</td>\r
-                       <td class=\r
-            % if pgstat.team == 5:\r
-            "blue"\r
-            % elif pgstat.team == 14:\r
-            "red"\r
-            % elif pgstat.team == 13:\r
-            "yellow"\r
+                       <td>${i}</td>\r
+                       % if player_id != '-':\r
+                       <td><a href="${request.route_url('player_info', id=player_id)}" title="Go to the player info page for this player">${nick}</a></td>\r
+                       % else:\r
+                       <td>${nick}</td>\r
+                       % endif\r
+            % if elo != '-':\r
+                       <td>${round(elo, 3)}</td>\r
+            % else:\r
+                       <td>${elo}</td>\r
             % endif\r
-            >\r
-            % if pgstat.player_id > 2:\r
-            <a href="${request.route_url('player_info', id=pgstat.player_id)}" title="Go to the player info page for this player">${pgstat.nick_html_colors()|n}</a></td>\r
+               </tr>\r
+               <% i = i+1 %>\r
+       % endfor\r
+       </tbody>\r
+</table>\r
+<p class="note"><a href="${request.route_url('rank_index', page=1, game_type_cd='duel')}" title="See more duel rankings">More...</a></p>\r
+</div>\r
+\r
+\r
+\r
+##### CTF RANKS #####\r
+<div class="table_block">\r
+<h2>CTF Ranks</h2>\r
+<table class="rank-table">\r
+       <thead>\r
+               <tr>\r
+                       <th>#</th>\r
+                       <th>Nick</th>\r
+                       <th>Elo</th>\r
+               </tr>\r
+       </thead>\r
+       <tbody>\r
+       <% i = 1 %>\r
+       % for (player_id, nick, elo) in ctf_ranks:\r
+               <tr>\r
+                       <td>${i}</td>\r
+                       % if player_id != '-':\r
+                       <td><a href="${request.route_url('player_info', id=player_id)}" title="Go to the player info page for this player">${nick}</a></td>\r
+                       % else:\r
+                       <td>${nick}</td>\r
+                       % endif\r
+            % if elo != '-':\r
+                       <td>${round(elo, 3)}</td>\r
             % else:\r
-            ${pgstat.nick_html_colors()|n}</td>\r
+                       <td>${elo}</td>\r
             % endif\r
                </tr>\r
-               % else:\r
+               <% i = i+1 %>\r
+       % endfor\r
+       </tbody>\r
+</table>\r
+<p class="note"><a href="${request.route_url('rank_index', page=1, game_type_cd='ctf')}" title="See more CTF rankings">More...</a></p>\r
+</div>\r
+\r
+\r
+\r
+##### DM RANKS #####\r
+<div class="table_block">\r
+<h2>DM Ranks</h2>\r
+<table class="rank-table">\r
+       <thead>\r
                <tr>\r
-                       <td>-</td>\r
-                       <td>-</td>\r
-                       <td>-</td>\r
-                       <td>-</td>\r
-                       <td>-</td>\r
-                       <td>-</td>\r
+                       <th>#</th>\r
+                       <th>Nick</th>\r
+                       <th>Elo</th>\r
                </tr>\r
-               % endif\r
-    % endfor\r
-    </tbody>\r
+       </thead>\r
+       <tbody>\r
+       <% i = 1 %>\r
+       % for (player_id, nick, elo) in dm_ranks:\r
+               <tr>\r
+                       <td>${i}</td>\r
+                       % if player_id != '-':\r
+                       <td><a href="${request.route_url('player_info', id=player_id)}" title="Go to the player info page for this player">${nick}</a></td>\r
+                       % else:\r
+                       <td>${nick}</td>\r
+                       % endif\r
+            % if elo != '-':\r
+                       <td>${round(elo, 3)}</td>\r
+            % else:\r
+                       <td>${elo}</td>\r
+            % endif\r
+               </tr>\r
+               <% i = i+1 %>\r
+       % endfor\r
+       </tbody>\r
 </table>\r
+<p class="note"><a href="${request.route_url('rank_index', page=1, game_type_cd='dm')}" title="See more deathmatch rankings">More...</a></p>\r
+</div>\r
+\r
+\r
 \r
 ##### TOP PLAYERS #####\r
 <div class="table_block">\r
@@ -64,7 +120,7 @@ Main Page - ${parent.title()}
                <tr>\r
                        <th>#</th>\r
                        <th>Nick</th>\r
-                       <th>Playing Time</th>\r
+                       <th class="play-time">Play Time</th>\r
                </tr>\r
        </thead>\r
        <tbody>\r
@@ -77,12 +133,13 @@ Main Page - ${parent.title()}
                        % else:\r
                        <td>${nick}</td>\r
                        % endif\r
-                       <td>${alivetime}</td>\r
+                       <td class="play-time">${alivetime}</td>\r
                </tr>\r
                <% i = i+1 %>\r
        % endfor\r
        </tbody>\r
 </table>\r
+<p class="note">*Most active stats are from the past 7 days</p>\r
 </div>\r
 \r
 ##### TOP SERVERS #####\r
@@ -93,7 +150,7 @@ Main Page - ${parent.title()}
                <tr>\r
                        <th>#</th>\r
                        <th>Server</th>\r
-                       <th>Games</th>\r
+                       <th>Games</th>\r
                </tr>\r
        </thead>\r
        <tbody>\r
@@ -122,7 +179,7 @@ Main Page - ${parent.title()}
                <tr>\r
                        <th>#</th>\r
                        <th>Map</th>\r
-                       <th>Games</th>\r
+                       <th>Games</th>\r
                </tr>\r
        </thead>\r
        <tbody>\r
@@ -142,3 +199,60 @@ Main Page - ${parent.title()}
        </tbody>\r
 </table>\r
 </div>\r
+\r
+\r
+\r
+##### RECENT GAMES #####\r
+<div class="table_block">\r
+<h2>Recent Games</h2>\r
+<table id="recent-games">\r
+       <thead>\r
+               <tr>\r
+                       <th>Game #</th>\r
+                       <th>Type</th>\r
+                       <th>Server</th>\r
+                       <th>Map</th>\r
+                       <th>Time</th>\r
+                       <th>Winner</th>\r
+               </tr>\r
+       </thead>\r
+       <tbody>\r
+       % for (game, server, map, pgstat) in recent_games:\r
+               % if game != '-':\r
+               <tr>\r
+                       <td><a href="${request.route_url('game_info', id=game.game_id)}" title="View detailed information about this game">${game.game_id}</a></td>\r
+                       <td class="gt_icon"><img title="${game.game_type_cd}" src="/static/images/icons/24x24/${game.game_type_cd}.png" alt="${game.game_type_cd}" /></td>\r
+                       <td><a href="${request.route_url('server_info', id=server.server_id)}" title="Go to the detail page for this server">${server.name}</a></td>\r
+                       <td><a href="${request.route_url('map_info', id=map.map_id)}" title="Go to the map detail page for this map">${map.name}</a></td>\r
+                       <td>${game.start_dt.strftime('%m/%d/%Y %H:%M')}</td>\r
+                       <td class=\r
+            % if pgstat.team == 5:\r
+            "blue"\r
+            % elif pgstat.team == 14:\r
+            "red"\r
+            % elif pgstat.team == 13:\r
+            "yellow"\r
+            % endif\r
+            >\r
+            % if pgstat.player_id > 2:\r
+            <a href="${request.route_url('player_info', id=pgstat.player_id)}" title="Go to the player info page for this player">${pgstat.nick_html_colors()|n}</a></td>\r
+            % else:\r
+            ${pgstat.nick_html_colors()|n}</td>\r
+            % endif\r
+               </tr>\r
+               % else:\r
+               <tr>\r
+                       <td>-</td>\r
+                       <td>-</td>\r
+                       <td>-</td>\r
+                       <td>-</td>\r
+                       <td>-</td>\r
+                       <td>-</td>\r
+               </tr>\r
+               % endif\r
+    % endfor\r
+    </tbody>\r
+</table>\r
+</div>\r
+\r
+\r
index 22b12918eeeae7df0baa3fbc31978eb54e779a14..d3a472517ecd811270ad7aa5d33115ca16f535aa 100755 (executable)
@@ -18,6 +18,42 @@ def main_index(request):
     leaderboard_count = 10
     recent_games_count = 20
 
+    # top ranked duelers
+    duel_ranks = DBSession.query(Player.player_id, Player.nick, PlayerElo.elo).\
+            filter(Player.player_id==PlayerElo.player_id).\
+            filter(PlayerElo.game_type_cd=='duel').\
+            order_by(expr.desc(PlayerElo.elo)).all()[0:10]
+
+    duel_ranks = [(player_id, html_colors(nick), elo) \
+            for (player_id, nick, elo) in duel_ranks]
+
+    for i in range(leaderboard_count-len(duel_ranks)):
+        duel_ranks.append(('-', '-', '-'))
+
+    # top ranked CTF-ers
+    ctf_ranks = DBSession.query(Player.player_id, Player.nick, PlayerElo.elo).\
+            filter(Player.player_id==PlayerElo.player_id).\
+            filter(PlayerElo.game_type_cd=='ctf').\
+            order_by(expr.desc(PlayerElo.elo)).all()[0:10]
+
+    ctf_ranks = [(player_id, html_colors(nick), elo) \
+            for (player_id, nick, elo) in ctf_ranks]
+
+    for i in range(leaderboard_count-len(ctf_ranks)):
+        ctf_ranks.append(('-', '-', '-'))
+
+    # top ranked DM-ers
+    dm_ranks = DBSession.query(Player.player_id, Player.nick, PlayerElo.elo).\
+            filter(Player.player_id==PlayerElo.player_id).\
+            filter(PlayerElo.game_type_cd=='dm').\
+            order_by(expr.desc(PlayerElo.elo)).all()[0:10]
+
+    dm_ranks = [(player_id, html_colors(nick), elo) \
+            for (player_id, nick, elo) in dm_ranks]
+
+    for i in range(leaderboard_count-len(dm_ranks)):
+        dm_ranks.append(('-', '-', '-'))
+
     # top players by playing time
     top_players = DBSession.query(Player.player_id, Player.nick, 
             func.sum(PlayerGameStat.alivetime)).\
@@ -76,4 +112,7 @@ def main_index(request):
             'top_servers':top_servers,
             'top_maps':top_maps,
             'recent_games':recent_games,
+            'duel_ranks':duel_ranks,
+            'ctf_ranks':ctf_ranks,
+            'dm_ranks':dm_ranks,
             }