]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Store player-to-map captimes by mod.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 13 Jun 2015 13:23:10 +0000 (09:23 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 13 Jun 2015 13:23:10 +0000 (09:23 -0400)
xonstat/models.py
xonstat/views/submission.py

index b496104952b7708e35feb6fa19895ddeddcde546..a8de35a489fc77815ea5334ceb2b1e60ee99c999 100644 (file)
@@ -258,14 +258,16 @@ class PlayerRank(object):
 
 class PlayerCaptime(object):
     def __init__(self, player_id=None, game_id=None, map_id=None,
-            fastest_cap=None):
+            fastest_cap=None, mod=None):
         self.player_id = player_id
         self.game_id = game_id
         self.map_id = map_id
         self.fastest_cap = fastest_cap
+        self.mod = mod
 
     def __repr__(self):
-        return "<PlayerCaptime(pid=%s, map_id=%s)>" % (self.player_id, self.map_id)
+        return "<PlayerCaptime(pid=%s, map_id=%s, mod=%s)>" % (self.player_id,
+                self.map_id, self.mod)
 
     def fuzzy_date(self):
         return pretty_date(self.create_dt)
index 18d06299a0a3fece112fa2c872c02fb7452c9372..6792fc75511d946e97fb1a31475a5204231c2a4a 100644 (file)
@@ -319,7 +319,7 @@ def register_new_nick(session, player, new_nick):
     session.add(player)
 
 
-def update_fastest_cap(session, player_id, game_id,  map_id, captime):
+def update_fastest_cap(session, player_id, game_id, map_id, captime, mod):
     """
     Check the fastest cap time for the player and map. If there isn't
     one, insert one. If there is, check if the passed time is faster.
@@ -333,7 +333,7 @@ def update_fastest_cap(session, player_id, game_id,  map_id, captime):
     # then check to see if the new captime is faster
     try:
         cur_fastest_cap = session.query(PlayerCaptime).filter_by(
-            player_id=player_id, map_id=map_id).one()
+            player_id=player_id, map_id=map_id, mod=mod).one()
 
         # current captime is faster, so update
         if captime < cur_fastest_cap.fastest_cap:
@@ -344,7 +344,8 @@ def update_fastest_cap(session, player_id, game_id,  map_id, captime):
 
     except NoResultFound, e:
         # none exists, so insert
-        cur_fastest_cap = PlayerCaptime(player_id, game_id, map_id, captime)
+        cur_fastest_cap = PlayerCaptime(player_id, game_id, map_id, captime,
+                mod)
         session.add(cur_fastest_cap)
         session.flush()
 
@@ -678,7 +679,7 @@ def create_game_stat(session, game_meta, game, server, gmap, player, events):
             pgstat.fastest = datetime.timedelta(seconds=float(value)/100)
             if game.game_type_cd == 'ctf':
                 update_fastest_cap(session, player.player_id, game.game_id,
-                        gmap.map_id, pgstat.fastest)
+                        gmap.map_id, pgstat.fastest, game.mod)
 
     # there is no "winning team" field, so we have to derive it
     if wins and pgstat.team is not None and game.winner is None: