]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add the most recent game info to the hashkey view.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 18 Aug 2013 18:31:16 +0000 (14:31 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 18 Aug 2013 18:31:16 +0000 (14:31 -0400)
xonstat/templates/player_hashkey_info_text.mako
xonstat/views/player.py

index 7b5f2ba671c845d766882dcb70787cf2db6bfe12..a44629e5306bde3c36f4e9d7bf8b5503a737354d 100644 (file)
@@ -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:
index 87967b9e3d23e04deeb8c5d0ec697f45784b7329..774672903c7203c863bed85af7f25f60638c2988 100644 (file)
@@ -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,
     }