]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/views/submission.py
Use score-scaling Elo for non-duels.
[xonotic/xonstat.git] / xonstat / views / submission.py
index 68610cf1ff92806e4ca52cc5b4e077ef6b21ec3a..78f02c94512301948da85053458c4d563f1726a8 100644 (file)
@@ -8,6 +8,7 @@ from pyramid.response import Response
 from sqlalchemy import Sequence
 from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
 from xonstat.d0_blind_id import d0_blind_id_verify
+from xonstat.elo import process_elos
 from xonstat.models import *
 from xonstat.util import strip_colors, qfont_decode
 
@@ -273,6 +274,9 @@ def create_game(session=None, start_dt=None, game_type_cd=None,
     try:
         session.query(Game).filter(Game.server_id==server_id).\
                 filter(Game.match_id==match_id).one()
+
+        log.debug("Error: game with same server and match_id found! Ignoring.")
+
         # if a game under the same server and match_id found, 
         # this is a duplicate game and can be ignored
         raise pyramid.httpexceptions.HTTPOk('OK')
@@ -375,19 +379,19 @@ def create_player_game_stat(session=None, player=None,
 
     for (key,value) in player_events.items():
         if key == 'n': pgstat.nick = value[:128]
-        if key == 't': pgstat.team = value
-        if key == 'rank': pgstat.rank = value
+        if key == 't': pgstat.team = int(value)
+        if key == 'rank': pgstat.rank = int(value)
         if key == 'alivetime': 
             pgstat.alivetime = datetime.timedelta(seconds=int(round(float(value))))
-        if key == 'scoreboard-drops': pgstat.drops = value
-        if key == 'scoreboard-returns': pgstat.returns = value
-        if key == 'scoreboard-fckills': pgstat.carrier_frags = value
-        if key == 'scoreboard-pickups': pgstat.pickups = value
-        if key == 'scoreboard-caps': pgstat.captures = value
-        if key == 'scoreboard-score': pgstat.score = value
-        if key == 'scoreboard-deaths': pgstat.deaths = value
-        if key == 'scoreboard-kills': pgstat.kills = value
-        if key == 'scoreboard-suicides': pgstat.suicides = value
+        if key == 'scoreboard-drops': pgstat.drops = int(value)
+        if key == 'scoreboard-returns': pgstat.returns = int(value)
+        if key == 'scoreboard-fckills': pgstat.carrier_frags = int(value)
+        if key == 'scoreboard-pickups': pgstat.pickups = int(value)
+        if key == 'scoreboard-caps': pgstat.captures = int(value)
+        if key == 'scoreboard-score': pgstat.score = int(value)
+        if key == 'scoreboard-deaths': pgstat.deaths = int(value)
+        if key == 'scoreboard-kills': pgstat.kills = int(value)
+        if key == 'scoreboard-suicides': pgstat.suicides = int(value)
 
     # check to see if we had a name, and if
     # not use an anonymous handle
@@ -402,7 +406,7 @@ def create_player_game_stat(session=None, player=None,
     # if the player is ranked #1 and it is a team game, set the game's winner
     # to be the team of that player
     # FIXME: this is a hack, should be using the 'W' field (not present)
-    if pgstat.rank == '1' and pgstat.team:
+    if pgstat.rank == 1 and pgstat.team:
         game.winner = pgstat.team
         session.add(game)
 
@@ -609,7 +613,7 @@ def stats_submit(request):
 
         # update elos
         try:
-            game.process_elos(session)
+            process_elos(game, session)
         except Exception as e:
             log.debug('Error (non-fatal): elo processing failed.')