From 9f1516200c67ff01d51b4b929d4b9d7ff1ae3bde Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Wed, 21 Dec 2011 22:24:24 -0500 Subject: [PATCH] Do not store blank games. --- xonstat/views/submission.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xonstat/views/submission.py b/xonstat/views/submission.py index 66dcd11..1f72df5 100755 --- a/xonstat/views/submission.py +++ b/xonstat/views/submission.py @@ -13,6 +13,29 @@ from xonstat.util import strip_colors, qfont_decode log = logging.getLogger(__name__) + +def is_blank_game(players): + """Determine if this is a blank game or not. A blank game is either: + + 1) a match that ended in the warmup stage, where accuracy events are not + present + + 2) a match in which no player made a positive or negative score AND was + on the scoreboard + """ + flg_nonzero_score = False + flg_acc_events = False + + for events in players: + if is_real_player(events): + for (key,value) in events.items(): + if key == 'scoreboard-score' and value != '0': + flg_nonzero_score = True + if key.startswith('acc-'): + flg_acc_events = True + + return flg_nonzero_score and flg_acc_events + def get_remote_addr(request): """Get the Xonotic server's IP address""" if 'X-Forwarded-For' in request.headers: @@ -537,6 +560,10 @@ def stats_submit(request): log.debug("ERROR: Not enough real players") raise pyramid.httpexceptions.HTTPOk("OK") + if is_blank_game(players): + log.debug("ERROR: Blank game") + raise pyramid.httpexceptions.HTTPOk("OK") + # FIXME: if we have two players and game type is 'dm', # change this into a 'duel' gametype. This should be # removed when the stats actually send 'duel' instead of 'dm' -- 2.39.2