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>${game_stats['total_alivetime']} </small><br />
- Games Played: <small>${game_stats['total_games_played']} </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 />
Average Rank: <small>${game_stats['avg_rank']} </small><br />
% if elos_display is not None and len(elos_display) > 0:
Elo:
import logging\r
import re\r
import sqlalchemy as sa\r
+import sqlalchemy.sql.functions as func\r
import time\r
from pyramid.response import Response\r
from pyramid.url import current_route_url\r
}\r
\r
\r
+def games_played(player_id):\r
+ """\r
+ Provides a breakdown by gametype of the games played by player_id.\r
+\r
+ Returns a tuple containing (total_games, games_breakdown), where\r
+ total_games is the absolute number of games played by player_id\r
+ and games_breakdown is an array containing (game_type_cd, # games)\r
+ """\r
+ games_played = DBSession.query(Game.game_type_cd, func.count()).\\r
+ filter(Game.game_id == PlayerGameStat.game_id).\\r
+ filter(PlayerGameStat.player_id == player_id).\\r
+ group_by(Game.game_type_cd).\\r
+ order_by(func.count().desc()).all()\r
+\r
+ total = 0\r
+ for (game_type_cd, games) in games_played:\r
+ total += games\r
+\r
+ return (total, games_played)\r
+\r
+\r
def player_info(request):\r
"""\r
Provides detailed information on a specific player\r
player = DBSession.query(Player).filter_by(player_id=player_id).\\r
filter(Player.active_ind == True).one()\r
\r
+ (total_games, games_breakdown) = games_played(player.player_id)\r
+\r
elos = DBSession.query(PlayerElo).filter_by(player_id=player_id).\\r
filter(PlayerElo.game_type_cd.in_(['ctf','duel','dm'])).\\r
order_by(PlayerElo.elo.desc()).all()\r
weapon_stats = None\r
game_stats = None\r
recent_games = None\r
+ total_games = None\r
+ games_breakdown = None\r
\r
return {'player':player, \r
'elos_display':elos_display,\r
'recent_games':recent_games,\r
'weapon_stats':weapon_stats,\r
- 'game_stats':game_stats}\r
+ 'game_stats':game_stats, \r
+ 'total_games':total_games,\r
+ 'games_breakdown':games_breakdown}\r
\r
\r
def player_game_index(request):\r