dataType: 'json',
success: plot_dmg_graph
});
-
-
})
</script>
% endif
% else:
<div class="row">
- <div class="span8">
+ <div class="span12">
<h2>${player.nick_html_colors()|n}</h2>
+ </div>
+</div>
+
+<div class="row">
+ <div class="span6">
+ <p>
+ Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
+
+ Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
+
+ Playing Time: <small>${total_stats['alivetime']} </small><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 fav_map is not None:
+ Favorite Map: <small><a href="${request.route_url('map_info', id=fav_map.map_id)}" title="view map info">${fav_map.name}</a></small><br />
+ % endif
+ </p>
+ </div>
+ <div class="span6">
<p>
- Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
- Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
- Playing Time: <small>${total_stats['alivetime']} </small><br />
% 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
- <% 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 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>
+ <small><i>*preliminary Elo</i></small><br />
%endif
% endif
</p>
return total_stats
+def _get_fav_map(player_id):
+ """
+ Get the player's favorite map. The favorite map is defined
+ as the map that he or she has played the most in the past
+ 90 days.
+
+ Returns a map object.
+ """
+ # 90 day window
+ back_then = datetime.datetime.utcnow() - datetime.timedelta(days=90)
+
+ fav_map = DBSession.query(Map).\
+ filter(Game.game_id == PlayerGameStat.game_id).\
+ filter(Game.map_id == Map.map_id).\
+ filter(PlayerGameStat.player_id == player_id).\
+ filter(PlayerGameStat.create_dt > back_then).\
+ group_by(Map.map_id).\
+ order_by(func.count().desc()).\
+ limit(1).one()
+
+ return fav_map
+
+
def get_accuracy_stats(player_id, weapon_cd, games):
"""
Provides accuracy for weapon_cd by player_id for the past N games.
# games breakdown - N games played (X ctf, Y dm) etc
(total_games, games_breakdown) = _get_games_played(player.player_id)
+ # favorite map from the past 90 days
+ fav_map = _get_fav_map(player.player_id)
# friendly display of elo information and preliminary status
elos = DBSession.query(PlayerElo).filter_by(player_id=player_id).\
total_games = None
games_breakdown = None
recent_weapons = []
+ fav_map = None
return {'player':player,
'elos_display':elos_display,
'total_games':total_games,
'games_breakdown':games_breakdown,
'recent_weapons':recent_weapons,
+ 'fav_map':fav_map,
}