]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/views/submission.py
Add a separate JSON view for summary stats.
[xonotic/xonstat.git] / xonstat / views / submission.py
index a830a3f14c59499fadb6f9cbead27efa9be509ec..085ed2b1f8d04cfc3a7bc3fbc171259e54631782 100644 (file)
@@ -405,6 +405,13 @@ def should_do_weapon_stats(game_type_cd):
     return game_type_cd not in {'cts'}
 
 
+def should_do_frag_matrix(game_type_cd):
+    """True if the game type should record frag matrix values. False otherwise."""
+    return game_type_cd in {
+        'as', 'ca', 'ctf', 'dm', 'dom', 'ft', 'freezetag', 'ka', 'kh', 'rune', 'tdm',
+    }
+
+
 def gametype_elo_eligible(game_type_cd):
     """True of the game type should process Elos. False otherwise."""
     return game_type_cd in {'duel', 'dm', 'ca', 'ctf', 'tdm', 'ka', 'ft'}
@@ -612,7 +619,7 @@ def create_game(session, game_type_cd, server_id, map_id, match_id, start_dt, du
     game.mod = mod[:64]
 
     # There is some drift between start_dt (provided by app) and create_dt
-    # (default in the database), so we'll make them the same until this is 
+    # (default in the database), so we'll make them the same until this is
     # resolved.
     game.create_dt = start_dt
 
@@ -1145,10 +1152,14 @@ def submit_stats(request):
             pgstat = create_game_stat(session, game, gmap, player, events)
             pgstats.append(pgstat)
 
-            frag_matrix = create_frag_matrix(session, submission.player_indexes, pgstat, events)
+            if should_do_frag_matrix(submission.game_type_cd):
+                create_frag_matrix(session, submission.player_indexes, pgstat, events)
 
             # player ranking opt-out
-            if 'r' in events and events['r'] != '0':
+            if 'r' in events and events['r'] == '0':
+                log.debug("Excluding player {} from ranking calculations (opt-out)"
+                          .format(pgstat.player_id))
+            else:
                 elo_pgstats.append(pgstat)
 
             if player.player_id > 1: