From: Ant Zucaro Date: Sun, 18 Aug 2013 18:31:16 +0000 (-0400) Subject: Add the most recent game info to the hashkey view. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c0375fa96904f45c7cc6d26cedefcb0dfd7d7ec3;p=xonotic%2Fxonstat.git Add the most recent game info to the hashkey view. --- diff --git a/xonstat/templates/player_hashkey_info_text.mako b/xonstat/templates/player_hashkey_info_text.mako index 7b5f2ba..a44629e 100644 --- a/xonstat/templates/player_hashkey_info_text.mako +++ b/xonstat/templates/player_hashkey_info_text.mako @@ -7,6 +7,8 @@ n ${player.nick} i ${player.player_id} e joined ${player_joined} e joined_dt ${player_joined_dt} +e last_seen ${most_recent_game.epoch} +e last_seen_dt ${most_recent_game.start_dt} % if player.active_ind == True: e active-ind 1 % else: diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 87967b9..7746729 100644 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -395,12 +395,12 @@ def get_elos(player_id): return elos -def get_recent_games(player_id): +def get_recent_games(player_id, limit=10): """ Provides a list of recent games for a player. Uses the recent_games_q helper. """ # recent games played in descending order - rgs = recent_games_q(player_id=player_id, force_player_id=True).limit(10).all() + rgs = recent_games_q(player_id=player_id, force_player_id=True).limit(limit).all() recent_games = [RecentGame(row) for row in rgs] return recent_games @@ -788,8 +788,8 @@ def player_damage_json(request): def player_hashkey_info_data(request): - (idfp, status) = verify_request(request) - print "player_hashkey_info_data [idfp={0} status={1}]".format(idfp, status) + #(idfp, status) = verify_request(request) + #print "player_hashkey_info_data [idfp={0} status={1}]".format(idfp, status) hashkey = request.matchdict['hashkey'] @@ -801,11 +801,12 @@ def player_hashkey_info_data(request): filter(Player.active_ind == True).\ filter(Hashkey.hashkey == hashkey).one() - games_played = get_games_played(player.player_id) - overall_stats = get_overall_stats(player.player_id) - fav_maps = get_fav_maps(player.player_id) - elos = get_elos(player.player_id) - ranks = get_ranks(player.player_id) + games_played = get_games_played(player.player_id) + overall_stats = get_overall_stats(player.player_id) + fav_maps = get_fav_maps(player.player_id) + elos = get_elos(player.player_id) + ranks = get_ranks(player.player_id) + most_recent_game = get_recent_games(player.player_id, 1)[0] except Exception as e: raise pyramid.httpexceptions.HTTPNotFound @@ -817,6 +818,7 @@ def player_hashkey_info_data(request): 'fav_maps':fav_maps, 'elos':elos, 'ranks':ranks, + 'most_recent_game':most_recent_game, } @@ -878,6 +880,7 @@ def player_hashkey_info_text(request): elos = player_info['elos'] ranks = player_info['ranks'] fav_maps = player_info['fav_maps'] + most_recent_game = player_info['most_recent_game'] # one-offs for things needing conversion for text/plain player_joined = timegm(player.create_dt.timetuple()) @@ -901,6 +904,7 @@ def player_hashkey_info_text(request): 'fav_maps': fav_maps, 'elos': elos, 'ranks': ranks, + 'most_recent_game': most_recent_game, }