From b8191d441a2a7b0353331e619a3481d00e324c70 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Thu, 19 Jan 2012 21:56:25 -0500 Subject: [PATCH] Add rankings to the main page. --- xonstat/static/css/style.css | 12 +- xonstat/static/js/default.js | 2 +- xonstat/templates/main_index.mako | 198 +++++++++++++++++++++++------- xonstat/views/main.py | 39 ++++++ 4 files changed, 206 insertions(+), 45 deletions(-) diff --git a/xonstat/static/css/style.css b/xonstat/static/css/style.css index 2dde72c..8f50faa 100755 --- a/xonstat/static/css/style.css +++ b/xonstat/static/css/style.css @@ -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; +} diff --git a/xonstat/static/js/default.js b/xonstat/static/js/default.js index af05cd4..f0096e8 100644 --- a/xonstat/static/js/default.js +++ b/xonstat/static/js/default.js @@ -60,7 +60,7 @@ function init_datatables() { $("#recent-games").dataTable({ "bPaginate": false, "bLengthChange": false, - "bFilter": true, + "bFilter": false, "bSort": true, "bInfo": false, "bAutoWidth": false, diff --git a/xonstat/templates/main_index.mako b/xonstat/templates/main_index.mako index 132a943..397d1c9 100755 --- a/xonstat/templates/main_index.mako +++ b/xonstat/templates/main_index.mako @@ -4,57 +4,113 @@ Main Page - ${parent.title()} - -##### RECENT GAMES ##### -

Recent Games

- +##### DUEL RANKS ##### +
+

Duel Ranks

+
- - - - - - + + + - % for (game, server, map, pgstat) in recent_games: - % if game != '-': + <% i = 1 %> + % for (player_id, nick, elo) in duel_ranks: - - - - - - + % if player_id != '-': + + % else: + + % endif + % if elo != '-': + + % else: + % endif - > - % if pgstat.player_id > 2: - ${pgstat.nick_html_colors()|n} + + <% i = i+1 %> + % endfor + +
Game #TypeServerMapTimeWinner#NickElo
${game.game_id}${game.game_type_cd}${server.name}${map.name}${game.start_dt.strftime('%m/%d/%Y %H:%M')}${i}${nick}${nick}${round(elo, 3)}${elo}
+

More...

+ + + + +##### CTF RANKS ##### +
+

CTF Ranks

+ + + + + + + + + + <% i = 1 %> + % for (player_id, nick, elo) in ctf_ranks: + + + % if player_id != '-': + + % else: + + % endif + % if elo != '-': + % else: - ${pgstat.nick_html_colors()|n} + % endif - % else: + <% i = i+1 %> + % endfor + +
#NickElo
${i}${nick}${nick}${round(elo, 3)}${elo}
+

More...

+
+ + + +##### DM RANKS ##### +
+

DM Ranks

+ + - - - - - - + + + - % endif - % endfor - + + + <% i = 1 %> + % for (player_id, nick, elo) in dm_ranks: + + + % if player_id != '-': + + % else: + + % endif + % if elo != '-': + + % else: + + % endif + + <% i = i+1 %> + % endfor +
------#NickElo
${i}${nick}${nick}${round(elo, 3)}${elo}
+

More...

+
+ + ##### TOP PLAYERS #####
@@ -64,7 +120,7 @@ Main Page - ${parent.title()} # Nick - Playing Time + Play Time @@ -77,12 +133,13 @@ Main Page - ${parent.title()} % else: ${nick} % endif - ${alivetime} + ${alivetime} <% i = i+1 %> % endfor +

*Most active stats are from the past 7 days

##### TOP SERVERS ##### @@ -93,7 +150,7 @@ Main Page - ${parent.title()} # Server - # Games + Games @@ -122,7 +179,7 @@ Main Page - ${parent.title()} # Map - # Games + Games @@ -142,3 +199,60 @@ Main Page - ${parent.title()} + + + +##### RECENT GAMES ##### +
+

Recent Games

+ + + + + + + + + + + + + % for (game, server, map, pgstat) in recent_games: + % if game != '-': + + + + + + + + % else: + ${pgstat.nick_html_colors()|n} + % endif + + % else: + + + + + + + + + % endif + % endfor + +
Game #TypeServerMapTimeWinner
${game.game_id}${game.game_type_cd}${server.name}${map.name}${game.start_dt.strftime('%m/%d/%Y %H:%M')} + % if pgstat.player_id > 2: + ${pgstat.nick_html_colors()|n}
------
+
+ + diff --git a/xonstat/views/main.py b/xonstat/views/main.py index 22b1291..d3a4725 100755 --- a/xonstat/views/main.py +++ b/xonstat/views/main.py @@ -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, } -- 2.39.2