+import datetime
import logging
import math
import random
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()
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))