From: Ant Zucaro Date: Mon, 16 Jan 2012 21:04:51 +0000 (-0500) Subject: Remove elo values when k==0. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=adec5dabdf2b4d293b974ba189732e93d5d2ed60;p=xonotic%2Fxonstat.git Remove elo values when k==0. --- diff --git a/xonstat/models.py b/xonstat/models.py index c6a1485..9925fc7 100755 --- a/xonstat/models.py +++ b/xonstat/models.py @@ -88,9 +88,13 @@ class Game(object): if game_type_cd is None: game_type_cd = self.game_type_cd - duration = session.query(func.max(PlayerGameStat.alivetime)).\ - filter(PlayerGameStat.game_id==self.game_id).\ - one() + # we do not have the actual duration of the game, so use the + # maximum alivetime of the players instead + duration = 0 + for d in session.query(func.max(PlayerGameStat.alivetime)).\ + filter(PlayerGameStat.game_id==self.game_id).\ + one(): + duration = d.seconds scores = {} alivetimes = {} @@ -119,7 +123,11 @@ class Game(object): for pid in player_ids: elos[pid].k = KREDUCTION.eval(elos[pid].games, alivetimes[pid], - duration.seconds) + duration) + if elos[pid].k == 0: + del(elos[pid]) + del(scores[pid]) + del(alivetimes[pid]) elos = self.update_elos(elos, scores, ELOPARMS)