parent
446d6afc71
commit
25829377a1
|
@ -57,12 +57,17 @@ def activity_results(form):
|
||||||
print(query)
|
print(query)
|
||||||
sessions = SessionResult.objects.raw(query)
|
sessions = SessionResult.objects.raw(query)
|
||||||
activity = {}
|
activity = {}
|
||||||
|
last_session = {}
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
time = -safe_int(session.unix) if session.action == 1 else safe_int(session.unix)
|
time = -safe_int(session.unix) if session.action == 1 else safe_int(session.unix)
|
||||||
if session.player in activity:
|
if session.player in activity:
|
||||||
|
if last_session[session.player] == session.action:
|
||||||
|
continue
|
||||||
activity[session.player] += time
|
activity[session.player] += time
|
||||||
|
last_session[session.player] = session.action
|
||||||
else:
|
else:
|
||||||
activity[session.player] = time
|
activity[session.player] = time
|
||||||
|
last_session[session.player] = session.action
|
||||||
results = []
|
results = []
|
||||||
for player, time in activity.items():
|
for player, time in activity.items():
|
||||||
results.append(ActivityResult(player, time))
|
results.append(ActivityResult(player, time))
|
||||||
|
|
Loading…
Reference in New Issue