From 4921873791d8dfb088c585e81e8272459e64d8b4 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 7 Oct 2017 09:06:23 -0400 Subject: [PATCH] Only store frag matrix rows if there is actually something in them. --- xonstat/views/submission.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 0f2b3cd..a830a3f 100644 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -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): -- 2.39.2