<div id="gbtabcontainer" class="tabbable tabs-below">
<div class="tab-content">
% for g in games_played:
+ % if not g.game_type_cd in ['cq']:
<div class="tab-pane fade in
% if g.game_type_cd == 'overall':
active
<p>
% if g.game_type_cd in overall_stats:
Last Played: <small><span class="abstime" data-epoch="${overall_stats[g.game_type_cd].last_played_epoch}" title="${overall_stats[g.game_type_cd].last_played.strftime('%a, %d %b %Y %H:%M:%S UTC')}"> ${overall_stats[g.game_type_cd].last_played_fuzzy} </span> <br /></small>
+ % else:
+ <small><br /></small>
% endif
- Games Played: <small>${g.games} <br /></small>
+ Games Played:
+ % if g.game_type_cd == 'overall':
+ <small><a href="${request.route_url("player_game_index", player_id=player.player_id)}" title="View recent games">
+ % else:
+ <small><a href="${request.route_url("player_game_index", player_id=player.player_id, _query={'type':g.game_type_cd})}" title="View recent ${overall_stats[g.game_type_cd].game_type_descr} games">
+ % endif
+ ${g.games}</a> <br /></small>
Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
% if g.game_type_cd in fav_maps:
- Favorite Map: <small>${fav_maps[g.game_type_cd].map_name} <br /></small>
+ Favorite Map: <small><a href="${request.route_url("map_info", id=fav_maps[g.game_type_cd].map_id)}" title="Go to the detail page for this map">${fav_maps[g.game_type_cd].map_name}</a> <br /></small>
+ % else:
+ <small><br /></small>
% endif
% if g.game_type_cd == 'ctf':
% if overall_stats[g.game_type_cd].total_captures is not None:
- <small><a href="${request.route_url("player_captimes", id=player.player_id)}">Fastest flag captures...</a></small>
+ <small><a href="${request.route_url("player_captimes", id=player.player_id)}">Fastest flag captures...</a> <br /></small>
% else:
<small><br /></small>
% endif
% if overall_stats[g.game_type_cd].k_d_ratio is not None:
Kill Ratio: <small>${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 /></small>
% endif
+ % else:
+ <small><br /></small>
% endif
% if g.game_type_cd in elos:
% else:
Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
% endif
+ % else:
+ <small><br /></small>
% endif
% if g.game_type_cd in ranks:
% if g.game_type_cd == 'overall':
- Best Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
-
+ Best Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)}) <br /></small>
% else:
- Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
+ Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (percentile: ${round(ranks[g.game_type_cd].percentile,2)}) <br /></small>
% endif
+ % else:
+ <small><br /></small>
% endif
% if g.game_type_cd == 'ctf':
- % if overall_stats[g.game_type_cd].cap_ratio is not None:
+ % if overall_stats[g.game_type_cd].cap_ratio is not None:
Cap Ratio: <small>${round(overall_stats[g.game_type_cd].cap_ratio,2)} (${overall_stats[g.game_type_cd].total_captures} captures, ${overall_stats[g.game_type_cd].total_pickups} pickups) <br /></small>
% else:
<small><br /></small>
</p>
</div>
</div>
+ % endif
% endfor
</div>
</div>
<ul id="gbtab" class="nav nav-tabs">
% for g in games_played:
<li>
- <a href="#tab-${g.game_type_cd}" data-toggle="tab" alt="${g.game_type_cd}" title="">
+ <a href="#tab-${g.game_type_cd}" data-toggle="tab" alt="${g.game_type_cd}" title="${overall_stats[g.game_type_cd].game_type_descr}">
<span class="sprite sprite-${g.game_type_cd}"> </span><br />
${g.game_type_cd} <br />
<small>(${g.games})</small>
- cap_ratio (ctf only)
- total_carrier_frags (ctf only)
- game_type_cd
+ - game_type_descr
The key to the dictionary is the game type code. There is also an
"overall" game_type_cd which sums the totals and computes the total ratios.
OverallStats = namedtuple('OverallStats', ['total_kills', 'total_deaths',
'k_d_ratio', 'last_played', 'last_played_epoch', 'last_played_fuzzy',
'total_playing_time', 'total_playing_time_secs', 'total_pickups', 'total_captures', 'cap_ratio',
- 'total_carrier_frags', 'game_type_cd'])
+ 'total_carrier_frags', 'game_type_cd', 'game_type_descr'])
- raw_stats = DBSession.query('game_type_cd', 'total_kills',
- 'total_deaths', 'last_played', 'total_playing_time',
+ raw_stats = DBSession.query('game_type_cd', 'game_type_descr',
+ 'total_kills', 'total_deaths', 'last_played', 'total_playing_time',
'total_pickups', 'total_captures', 'total_carrier_frags').\
from_statement(
"SELECT g.game_type_cd, "
+ "gt.descr game_type_descr, "
"Sum(pgs.kills) total_kills, "
"Sum(pgs.deaths) total_deaths, "
"Max(pgs.create_dt) last_played, "
"Sum(pgs.captures) total_captures, "
"Sum(pgs.carrier_frags) total_carrier_frags "
"FROM games g, "
+ "cd_game_type gt, "
"player_game_stats pgs "
"WHERE g.game_id = pgs.game_id "
+ "AND g.game_type_cd = gt.game_type_cd "
"AND pgs.player_id = :player_id "
- "GROUP BY g.game_type_cd "
+ "GROUP BY g.game_type_cd, game_type_descr "
"UNION "
- "SELECT 'overall' game_type_cd, "
+ "SELECT 'overall' game_type_cd, "
+ "'Overall' game_type_descr, "
"Sum(pgs.kills) total_kills, "
"Sum(pgs.deaths) total_deaths, "
"Max(pgs.create_dt) last_played, "
"Sum(pgs.pickups) total_pickups, "
"Sum(pgs.captures) total_captures, "
"Sum(pgs.carrier_frags) total_carrier_frags "
- "FROM games g, "
- "player_game_stats pgs "
- "WHERE g.game_id = pgs.game_id "
- "AND pgs.player_id = :player_id "
+ "FROM player_game_stats pgs "
+ "WHERE pgs.player_id = :player_id "
).params(player_id=player_id).all()
-
+
# to be indexed by game_type_cd
overall_stats = {}
-
+
for row in raw_stats:
# individual gametype ratio calculations
try:
total_captures=row.total_captures,
cap_ratio=cap_ratio,
total_carrier_frags=row.total_carrier_frags,
- game_type_cd=row.game_type_cd)
+ game_type_cd=row.game_type_cd,
+ game_type_descr=row.game_type_descr)
overall_stats[row.game_type_cd] = os
ranks = None
recent_games = None
recent_weapons = []
+ ## do not raise exceptions here (only for debugging)
+ #raise e
return {'player':player,
'games_played':games_played,
if player_id <= 2:
player_id = -1;
- #player_captimes = DBSession.query(PlayerCaptime).\
- # filter(PlayerCaptime.player_id==player_id).\
- # order_by(PlayerCaptime.fastest_cap).\
- # all()
-
PlayerCaptimes = namedtuple('PlayerCaptimes', ['fastest_cap', 'create_dt', 'create_dt_epoch', 'create_dt_fuzzy',
'player_id', 'game_id', 'map_id', 'map_name', 'server_id', 'server_name'])