]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/elo.py
Handle Elos properly when players have big alivetimes.
[xonotic/xonstat.git] / xonstat / elo.py
index 48a24e831bfd1a6dddbec61130aeb2314d63dfc2..74c49cd589137f6e4e15c974bff65238512368a2 100644 (file)
@@ -63,7 +63,15 @@ def process_elos(game, session, game_type_cd=None):
             filter(PlayerGameStat.player_id > 2).\
             all():
                 # scores are per second
-                scores[p] = s/float(a.seconds)
+                # with a short circuit to handle alivetimes > game
+                # durations, which can happen due to warmup being
+                # included (most often in duels)
+                if game.duration is not None:
+                    if a.seconds > game.duration.seconds:
+                        scores[p] = s/float(game.duration.seconds)
+                else:
+                    scores[p] = s/float(a.seconds)
+
                 alivetimes[p] = a.seconds
 
     player_ids = scores.keys()