From 25829377a176a664a21d0c41fa5d2835bac00af4 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Fri, 16 Aug 2019 12:42:29 -0500 Subject: [PATCH] Try to prevent corrupt activity Signed-off-by: Etzelia --- activity.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/activity.py b/activity.py index a26c2e8..74a9865 100644 --- a/activity.py +++ b/activity.py @@ -57,12 +57,17 @@ def activity_results(form): print(query) sessions = SessionResult.objects.raw(query) activity = {} + last_session = {} for session in sessions: time = -safe_int(session.unix) if session.action == 1 else safe_int(session.unix) if session.player in activity: + if last_session[session.player] == session.action: + continue activity[session.player] += time + last_session[session.player] = session.action else: activity[session.player] = time + last_session[session.player] = session.action results = [] for player, time in activity.items(): results.append(ActivityResult(player, time))