]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/views/player.py
Order player caps by date. Fixes #147.
[xonotic/xonstat.git] / xonstat / views / player.py
index 7e4dfcbbe33f6ea1e067abadfeef1548cb7b1b04..b38fcf2b7e02678c760b640e71b56e301a4a7cbc 100644 (file)
@@ -1037,7 +1037,7 @@ def player_captimes_data(request):
                 filter(PlayerCaptime.game_id==Game.game_id).\
                 filter(PlayerCaptime.map_id==Map.map_id).\
                 filter(Game.server_id==Server.server_id).\
-                order_by(expr.asc(PlayerCaptime.fastest_cap))  # or PlayerCaptime.create_dt
+                order_by(expr.desc(PlayerCaptime.create_dt))
 
         player_captimes = Page(pct_q, current_page, items_per_page=20, url=page_url)
 
@@ -1106,10 +1106,6 @@ def player_weaponstats_data_json(request):
         filter(PlayerWeaponStat.player_id == player_id).\
         filter(PlayerWeaponStat.game_id.in_(games_raw)).all()
 
-    # NVD3 expects data points for all weapons used across the
-    # set of games *for each* point on the x axis. This means populating
-    # zero-valued weapon stat entries for games where a weapon was not
-    # used in that game, but was used in another game for the set
     games_to_weapons = {}
     weapons_used = {}
     sum_avgs = {}
@@ -1122,6 +1118,9 @@ def player_weaponstats_data_json(request):
         weapons_used[ws.weapon_cd] = weapons_used.get(ws.weapon_cd, 0) + 1
         sum_avgs[ws.weapon_cd] = sum_avgs.get(ws.weapon_cd, 0) + float(ws.hit)/float(ws.fired)
 
+    # Creating zero-valued weapon stat entries for games where a weapon was not
+    # used in that game, but was used in another game for the set. This makes 
+    # the charts look smoother
     for game_id in games_to_weapons.keys():
         for weapon_cd in set(weapons_used.keys()) - set(games_to_weapons[game_id]):
             weapon_stats_raw.append(PlayerWeaponStat(player_id=player_id,