]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Only store frag matrix rows if there is actually something in them. frag-matrix
authorAnt Zucaro <azucaro@gmail.com>
Sat, 7 Oct 2017 13:06:23 +0000 (09:06 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 7 Oct 2017 13:06:23 +0000 (09:06 -0400)
xonstat/views/submission.py

index 0f2b3cd087ee543e9aeb353d756b51299ed69106..a830a3f14c59499fadb6f9cbead27efa9be509ec 100644 (file)
@@ -1068,12 +1068,14 @@ def create_frag_matrix(session, player_indexes, pgstat, events):
     matrix = {victim_index(k): int(v) for (k, v) in events.items()
               if k.startswith("kills-") and victim_index(k) in player_indexes}
 
-    pfm = PlayerGameFragMatrix(pgstat.game_id, pgstat.player_game_stat_id, pgstat.player_id,
-                               player_index, matrix)
+    if len(matrix) > 0:
+        pfm = PlayerGameFragMatrix(pgstat.game_id, pgstat.player_game_stat_id, pgstat.player_id,
+                                   player_index, matrix)
 
-    session.add(pfm)
-
-    return pfm
+        session.add(pfm)
+        return pfm
+    else:
+        return None
 
 
 def submit_stats(request):