The duration has been sent for a while as the 'D' line, but
it hasn't really been needed until now; it was just a nice thing
to have. Now Elo calculations are messing up because the warmup
time is being summed into player alivetimes. This duration field
can assist in creating a workaround. Having it, Elo calculations
can know the true maximum game time, so anything higher can be
brought down to the "floor" of the real duration of the match.
def create_game(session=None, start_dt=None, game_type_cd=None,
def create_game(session=None, start_dt=None, game_type_cd=None,
- server_id=None, map_id=None, winner=None, match_id=None):
+ server_id=None, map_id=None, winner=None, match_id=None,
+ duration=None):
"""
Creates a game. Parameters:
"""
Creates a game. Parameters:
server_id=server_id, map_id=map_id, winner=winner)
game.match_id = match_id
server_id=server_id, map_id=map_id, winner=winner)
game.match_id = match_id
+ try:
+ game.duration = datetime.timedelta(seconds=int(round(float(duration))))
+ except:
+ pass
+
try:
session.query(Game).filter(Game.server_id==server_id).\
filter(Game.match_id==match_id).one()
try:
session.query(Game).filter(Game.server_id==server_id).\
filter(Game.match_id==match_id).one()
if key in 'S' 'n':
value = unicode(value, 'utf-8')
if key in 'S' 'n':
value = unicode(value, 'utf-8')
- if key in 'V' 'T' 'G' 'M' 'S' 'C' 'R' 'W' 'I':
+ if key in 'V' 'T' 'G' 'M' 'S' 'C' 'R' 'W' 'I' 'D':
game_meta[key] = value
if key == 'P':
game_meta[key] = value
if key == 'P':
gmap = get_or_create_map(session=session, name=game_meta['M'])
gmap = get_or_create_map(session=session, name=game_meta['M'])
- # FIXME: use the gmtime instead of utcnow() when the timezone bug is
- # fixed
+ # duration is optional
+ if 'D' in game_meta:
+ duration = game_meta['D']
+ else:
+ duration = None
+
game = create_game(session=session,
start_dt=datetime.datetime.utcnow(),
#start_dt=datetime.datetime(
#*time.gmtime(float(game_meta['T']))[:6]),
server_id=server.server_id, game_type_cd=game_meta['G'],
game = create_game(session=session,
start_dt=datetime.datetime.utcnow(),
#start_dt=datetime.datetime(
#*time.gmtime(float(game_meta['T']))[:6]),
server_id=server.server_id, game_type_cd=game_meta['G'],
- map_id=gmap.map_id, match_id=game_meta['I'])
+ map_id=gmap.map_id, match_id=game_meta['I'],
+ duration=duration)
# find or create a record for each player
# and add stats for each if they were present at the end
# find or create a record for each player
# and add stats for each if they were present at the end