X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonstat.git;a=blobdiff_plain;f=xonstat%2Fviews%2Fplayer.py;h=c9e5290411d7185c68ab4cc338b30a7f2a49e0c4;hp=8db3c556b170345be289c448d1fe96f6056fd1d7;hb=fe2c574fdbacd574cfcb99a319224c01df8e38d3;hpb=b52cd596117bd2e52434d99b913e7155638e054f diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 8db3c55..c9e5290 100755 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -15,10 +15,24 @@ def player_index(request): """ Provides a list of all the current players. """ - players = DBSession.query(Player) + if 'page' in request.matchdict: + current_page = request.matchdict['page'] + else: + current_page = 1 + + try: + player_q = DBSession.query(Player).\ + filter(Player.player_id > 2).\ + order_by(Player.player_id) + + players = Page(player_q, current_page, url=page_url) + + + except Exception as e: + players = None + + return {'players':players, } - log.debug("testing logging; entered PlayerHandler.index()") - return {'players':players} def player_info(request): """ @@ -41,8 +55,6 @@ def player_info(request): "order by descr" ).params(player_id=player_id).all() - log.debug(weapon_stats) - recent_games = DBSession.query(PlayerGameStat, Game, Server, Map).\ filter(PlayerGameStat.player_id == player_id).\ filter(PlayerGameStat.game_id == Game.game_id).\ @@ -50,13 +62,54 @@ 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'], + game_stats['total_games_played']) = 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", + "total_games_played").\ + 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, count(*) total_games_played " + "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 + return {'player':player, 'recent_games':recent_games, - 'weapon_stats':weapon_stats} + 'weapon_stats':weapon_stats, + 'game_stats':game_stats} def player_game_index(request): @@ -88,39 +141,6 @@ def player_game_index(request): except Exception as e: player = None games = None - raise e return {'player':player, 'games':games} - - -def player_weapon_stats(request): - """ - List the accuracy statistics for the given player_id in a particular - game. - """ - game_id = request.matchdict['game_id'] - pgstat_id = request.matchdict['pgstat_id'] - try: - pwstats = DBSession.query(PlayerWeaponStat, Weapon).\ - filter(PlayerWeaponStat.weapon_cd==Weapon.weapon_cd).\ - filter_by(game_id=game_id).\ - filter_by(player_game_stat_id=pgstat_id).\ - order_by(Weapon.descr).\ - all() - - pgstat = DBSession.query(PlayerGameStat).\ - filter_by(player_game_stat_id=pgstat_id).one() - - game = DBSession.query(Game).filter_by(game_id=game_id).one() - - log.debug(pwstats) - log.debug(pgstat) - log.debug(game) - - except Exception as e: - pwstats = None - pgstat = None - game = None - raise e - return {'pwstats':pwstats, 'pgstat':pgstat, 'game':game}