From adec5dabdf2b4d293b974ba189732e93d5d2ed60 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Mon, 16 Jan 2012 16:04:51 -0500 Subject: [PATCH] Remove elo values when k==0. --- xonstat/models.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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) -- 2.39.2