From 7bb73ec899cfdff2f1cac0783ab650ebf7365c8c Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 13 Jun 2015 09:23:10 -0400 Subject: [PATCH] Store player-to-map captimes by mod. --- xonstat/models.py | 6 ++++-- xonstat/views/submission.py | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xonstat/models.py b/xonstat/models.py index b496104..a8de35a 100644 --- a/xonstat/models.py +++ b/xonstat/models.py @@ -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 "" % (self.player_id, self.map_id) + return "" % (self.player_id, + self.map_id, self.mod) def fuzzy_date(self): return pretty_date(self.create_dt) diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 18d0629..6792fc7 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -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: -- 2.39.2