Try to prevent corrupt activity

Signed-off-by: Etzelia <etzelia@hotmail.com>
develop
Etzelia 2019-08-16 12:42:29 -05:00
parent 446d6afc71
commit 25829377a1
No known key found for this signature in database
GPG Key ID: 3CAEB74806C4ADE5
1 changed files with 5 additions and 0 deletions

View File

@ -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))