]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Do not store blank games.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 22 Dec 2011 03:24:24 +0000 (22:24 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 22 Dec 2011 03:24:24 +0000 (22:24 -0500)
xonstat/views/submission.py

index 66dcd1107dc8ca57a30d683ea7eaa616680f85aa..1f72df59b2e32ee429bef5c9cd1687c35800d87d 100755 (executable)
@@ -13,6 +13,29 @@ from xonstat.util import strip_colors, qfont_decode
 \r
 log = logging.getLogger(__name__)\r
 \r
+\r
+def is_blank_game(players):\r
+    """Determine if this is a blank game or not. A blank game is either:\r
+\r
+    1) a match that ended in the warmup stage, where accuracy events are not\r
+    present\r
+\r
+    2) a match in which no player made a positive or negative score AND was\r
+    on the scoreboard\r
+    """\r
+    flg_nonzero_score = False\r
+    flg_acc_events = False\r
+\r
+    for events in players:\r
+        if is_real_player(events):\r
+            for (key,value) in events.items():\r
+                if key == 'scoreboard-score' and value != '0':\r
+                    flg_nonzero_score = True\r
+                if key.startswith('acc-'):\r
+                    flg_acc_events = True\r
+\r
+    return flg_nonzero_score and flg_acc_events\r
+\r
 def get_remote_addr(request):\r
     """Get the Xonotic server's IP address"""\r
     if 'X-Forwarded-For' in request.headers:\r
@@ -537,6 +560,10 @@ def stats_submit(request):
             log.debug("ERROR: Not enough real players")\r
             raise pyramid.httpexceptions.HTTPOk("OK")\r
 \r
+        if is_blank_game(players):\r
+            log.debug("ERROR: Blank game")\r
+            raise pyramid.httpexceptions.HTTPOk("OK")\r
+\r
         # FIXME: if we have two players and game type is 'dm',\r
         # change this into a 'duel' gametype. This should be\r
         # removed when the stats actually send 'duel' instead of 'dm'\r