(self.player_id, self.game_type_cd, self.elo)
+class PlayerRank(object):
+
+ def nick_html_colors(self):
+ if self.nick is None:
+ return "Anonymous Player"
+ else:
+ return html_colors(self.nick)
+
+
+ def __repr__(self):
+ return "<PlayerRank(pid=%s, gametype=%s, rank=%s)>" % \
+ (self.player_id, self.game_type_cd, self.rank)
+
+
def initialize_db(engine=None):
DBSession.configure(bind=engine)
Base.metadata.bind = engine
servers_table = MetaData.tables['servers']
player_nicks_table = MetaData.tables['player_nicks']
player_elos_table = MetaData.tables['player_elos']
+ player_ranks_table = MetaData.tables['player_ranks']
# now map the tables and the objects together
mapper(PlayerAchievement, achievements_table)
mapper(Server, servers_table)
mapper(PlayerNick, player_nicks_table)
mapper(PlayerElo, player_elos_table)
+ mapper(PlayerRank, player_ranks_table)
<th>Elo</th>\r
</tr>\r
<% i = 1 %>\r
-% for (rank, player) in ranks:\r
+% for rank in ranks:\r
<tr>\r
- <td>${i}</td>\r
- <td><a href="${request.route_url("player_info", id=rank.player_id)}" title="Go to this player's info page">${player.nick_html_colors()|n}</a></th>\r
+ <td>${rank.rank}</td>\r
+ <td><a href="${request.route_url("player_info", id=rank.player_id)}" title="Go to this player's info page">${rank.nick_html_colors()|n}</a></th>\r
<td>${round(rank.elo, 3)}</th>\r
</tr>\r
<% i += 1 %>\r
</table>\r
\r
<!-- navigation links -->\r
-${navlinks("rank_index_paged", ranks.page, ranks.last_page)}\r
+${navlinks("rank_index_paged", ranks.page, ranks.last_page, game_type_cd=game_type_cd)}\r
% endif\r
import re\r
import time\r
from pyramid.response import Response\r
-from sqlalchemy import desc\r
+from sqlalchemy import desc, func, over\r
from webhelpers.paginate import Page, PageURL\r
from xonstat.models import *\r
from xonstat.util import page_url\r
\r
game_type_cd = request.matchdict['game_type_cd']\r
\r
- ranks_q = DBSession.query(PlayerElo, Player).\\r
- filter(PlayerElo.game_type_cd==game_type_cd).\\r
- filter(PlayerElo.player_id==Player.player_id).\\r
- order_by(PlayerElo.elo.desc())\r
+ ranks_q = DBSession.query(PlayerRank).\\r
+ filter(PlayerRank.game_type_cd==game_type_cd).\\r
+ order_by(PlayerRank.rank)\r
\r
ranks = Page(ranks_q, current_page, url=page_url)\r
\r