]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Localize the last seen time for all game types.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 27 Sep 2012 02:16:40 +0000 (22:16 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 27 Sep 2012 02:16:40 +0000 (22:16 -0400)
xonstat/templates/player_info.mako
xonstat/views/player.py

index 10ec1ad6bf3a21123b67d9777de2372c0393c8a6..8bb282fa0d44e77dc6228fea777bf40923075acf 100644 (file)
@@ -211,7 +211,7 @@ Player Information
           <div class="span5">
             <p>
             % if g.game_type_cd in overall_stats:
-            Last Played: <small>${overall_stats[g.game_type_cd].last_played.strftime('%a, %d %b %Y %H:%M UTC')} <br /></small>
+            Last Played: <small><span class="abstime" data-epoch="${overall_stats[g.game_type_cd].last_played_epoch}" title="${overall_stats[g.game_type_cd].last_played.strftime('%a, %d %b %Y %H:%M:%S UTC')}"> ${overall_stats[g.game_type_cd].last_played_fuzzy} </span> <br /></small>
             % endif
 
             Games Played: <small>${g.games} <br /></small>
index 29ce3deb93ca70a8d3ca65198bd2698dbbc5cd30..87a14cf34da5d63aefa682bf10e71a1532c57d1e 100644 (file)
@@ -5,13 +5,14 @@ import re
 import sqlalchemy as sa
 import sqlalchemy.sql.functions as func
 import time
+from calendar import timegm
 from collections import namedtuple
 from pyramid.response import Response
 from pyramid.url import current_route_url
 from sqlalchemy import desc, distinct
 from webhelpers.paginate import Page, PageURL
 from xonstat.models import *
-from xonstat.util import page_url, to_json
+from xonstat.util import page_url, to_json, pretty_date
 
 log = logging.getLogger(__name__)
 
@@ -130,6 +131,8 @@ def get_overall_stats(player_id):
         - total_deaths
         - k_d_ratio
         - last_played (last time the player played the game type)
+        - last_played_epoch (same as above, but in seconds since epoch)
+        - last_played_fuzzy (same as above, but in relative date)
         - total_playing_time (total amount of time played the game type)
         - total_pickups (ctf only)
         - total_captures (ctf only)
@@ -141,8 +144,9 @@ def get_overall_stats(player_id):
     "overall" game_type_cd which sums the totals and computes the total ratios.
     """
     OverallStats = namedtuple('OverallStats', ['total_kills', 'total_deaths',
-        'k_d_ratio', 'last_played', 'total_playing_time', 'total_pickups',
-        'total_captures', 'cap_ratio', 'total_carrier_frags', 'game_type_cd'])
+        'k_d_ratio', 'last_played', 'last_played_epoch', 'last_played_fuzzy',
+        'total_playing_time', 'total_pickups', 'total_captures', 'cap_ratio',
+        'total_carrier_frags', 'game_type_cd'])
 
     raw_stats = DBSession.query('game_type_cd', 'total_kills',
             'total_deaths', 'last_played', 'total_playing_time',
@@ -201,6 +205,8 @@ def get_overall_stats(player_id):
                 total_deaths=row.total_deaths,
                 k_d_ratio=k_d_ratio,
                 last_played=row.last_played,
+                last_played_epoch=timegm(row.last_played.timetuple()),
+                last_played_fuzzy=pretty_date(row.last_played),
                 total_playing_time=row.total_playing_time,
                 total_pickups=row.total_pickups,
                 total_captures=row.total_captures,
@@ -220,6 +226,8 @@ def get_overall_stats(player_id):
             total_deaths=overall_deaths,
             k_d_ratio=overall_k_d_ratio,
             last_played=overall_last_played,
+            last_played_epoch=timegm(overall_last_played.timetuple()),
+            last_played_fuzzy=pretty_date(overall_last_played),
             total_playing_time=overall_playing_time,
             total_pickups=None,
             total_captures=None,