From: Ant Zucaro Date: Wed, 1 Jun 2011 13:43:22 +0000 (-0400) Subject: Add overall game stats to the player info page. Change template to suit. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=34ce0e7f432572d0cda4a6d83254b14fd9641e41;p=xonotic%2Fxonstat.git Add overall game stats to the player info page. Change template to suit. --- diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako index 2c2b7db..6982911 100755 --- a/xonstat/templates/player_info.mako +++ b/xonstat/templates/player_info.mako @@ -22,9 +22,48 @@ ${parent.title()} % endif +##### STATS ##### +% if game_stats: +

Overall Game Stats

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Playing Time${game_stats['total_alivetime']}Drops${game_stats['total_drops']}
Average Rank${game_stats['avg_rank']}Returns${game_stats['total_returns']}
Score${game_stats['total_score']}Carrier Kills${game_stats['total_carrier_frags']}
Kills${game_stats['total_kills']}Collects${game_stats['total_collects']}
Deaths${game_stats['total_deaths']}Destroys${game_stats['total_destroys']}
Suicides${game_stats['total_suicides']}Destroys (with key)${game_stats['total_destroys']}
Captures${game_stats['total_captures']}Pushes${game_stats['total_pushes']}
Pickups${game_stats['total_pickups']}Pushed${game_stats['total_pushed']}
+% endif + ##### ACCURACY ##### % if weapon_stats: -

Accuracy

+

Overall Accuracy

${accuracy(weapon_stats)} % endif @@ -39,4 +78,25 @@ ${accuracy(weapon_stats)} More games played by ${player.nick_html_colors()}... % endif - +##### RECENT GAMES (v2) #### + + + + + + + +% for (gamestat, game, server, map) in recent_games: + + + + + + +% endfor diff --git a/xonstat/views/player.py b/xonstat/views/player.py index debe810..4dbed66 100755 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -47,13 +47,52 @@ def player_info(request): filter(Game.map_id == Map.map_id).\ order_by(Game.game_id.desc())[0:10] + game_stats = {} + (game_stats['avg_rank'], game_stats['total_kills'], + game_stats['total_deaths'], game_stats['total_suicides'], + game_stats['total_score'], game_stats['total_time'], + game_stats['total_held'], game_stats['total_captures'], + game_stats['total_pickups'],game_stats['total_drops'], + game_stats['total_returns'], game_stats['total_collects'], + game_stats['total_destroys'], game_stats['total_dhk'], + game_stats['total_pushes'], game_stats['total_pushed'], + game_stats['total_carrier_frags'], + game_stats['total_alivetime']) = DBSession.\ + query("avg_rank", "total_kills", "total_deaths", + "total_suicides", "total_score", "total_time", "total_held", + "total_captures", "total_pickups", "total_drops", + "total_returns", "total_collects", "total_destroys", + "total_dhk", "total_pushes", "total_pushed", + "total_carrier_frags", "total_alivetime").\ + from_statement( + "select round(avg(rank)) avg_rank, sum(kills) total_kills, " + "sum(deaths) total_deaths, sum(suicides) total_suicides, " + "sum(score) total_score, sum(time) total_time, " + "sum(held) total_held, sum(captures) total_captures, " + "sum(pickups) total_pickups, sum(drops) total_drops, " + "sum(returns) total_returns, sum(collects) total_collects, " + "sum(destroys) total_destroys, sum(destroys_holding_key) total_dhk, " + "sum(pushes) total_pushes, sum(pushed) total_pushed, " + "sum(carrier_frags) total_carrier_frags, " + "sum(alivetime) total_alivetime " + "from player_game_stats " + "where player_id=:player_id" + ).params(player_id=player_id).one() + + for (key,value) in game_stats.items(): + if value == None: + game_stats[key] = '-' + except Exception as e: player = None weapon_stats = None + game_stats = None recent_games = None + raise e return {'player':player, 'recent_games':recent_games, - 'weapon_stats':weapon_stats} + 'weapon_stats':weapon_stats, + 'game_stats':game_stats} def player_game_index(request):
Game TypeMapResultPlayed
${game.game_type_cd}${map.name} + % if gamestat.team != None and gamestat.team == game.winner: + Win + % else: + Loss + % endif + ${game.start_dt}