X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=xonstat%2Felo.py;h=60da5311a15c3bad02a90df3e625979ac9278733;hb=d16882bddf4da58caa6bc9e1d6b423fe4152fd1f;hp=48a24e831bfd1a6dddbec61130aeb2314d63dfc2;hpb=36ee45a0e6f186a6978143f318a3bc7a75dd8fb0;p=xonotic%2Fxonstat.git diff --git a/xonstat/elo.py b/xonstat/elo.py index 48a24e8..60da531 100644 --- a/xonstat/elo.py +++ b/xonstat/elo.py @@ -1,3 +1,4 @@ +import datetime import logging import math import random @@ -63,8 +64,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) - alivetimes[p] = 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 and a.seconds > game.duration.seconds: + scores[p] = s/float(game.duration.seconds) + alivetimes[p] = game.duration.seconds + else: + scores[p] = s/float(a.seconds) + alivetimes[p] = a.seconds player_ids = scores.keys() @@ -178,6 +186,7 @@ def update_elos(game, session, elos, scores, ep): elos[pid].elo = new_elo elos[pid].games += 1 + elos[pid].update_dt = datetime.datetime.utcnow() log.debug("Setting Player {0}'s Elo delta to {1}. Elo is now {2} (was {3}).".format(pid, elo_deltas[pid], new_elo, old_elo))