Add update for profile last seen

This commit is contained in:
AndyGrant committed 2018-06-13 22:01:03 -04:00
1 parent 6755e43385
commit c792b9fd3b
5 files changed
+22 -7

No files matched your search

+2 -1
View File
@@ -1,4 +1,5 @@
*.pyc
Client/*
!Client/OpenBench.py
!Client/cleanup.sh
!Client/cleanup.sh
OpenBench/migrations/*
+1
View File
@@ -32,6 +32,7 @@ class Profile(Model):
repo = CharField(max_length=256, blank=True)
enabled = BooleanField(default=False)
approver = BooleanField(default=False)
updated = DateTimeField(auto_now=True)
def __str__(self):
return self.user.__str__()
+16 -5
View File
@@ -1,5 +1,6 @@
import math, requests, random
from django.utils import timezone
from django.db.models import F
from django.contrib.auth import authenticate
@@ -224,11 +225,19 @@ def update(request, user):
failed = sprt < test.lowerllr
finished = passed or failed
# Update total # of games played for the User
Profile.objects.filter(user=user).update(games=F('games') + games)
# Updating times manually since .update() won't invoke
updated = timezone.now()
# Just force an update to Machine.update
Machine.objects.filter(id=machineid).update()
# Update total # of games played for the User
Profile.objects.filter(user=user).update(
games=F('games') + games,
updated=updated
)
# Update last time we saw a result
Machine.objects.filter(id=machineid).update(
updated=updated
)
# Update for the new results
Result.objects.filter(id=resultid).update(
@@ -238,6 +247,7 @@ def update(request, user):
draws=F('draws') + draws,
crashes=F('crashes') + crashes,
timeloss=F('timeloss') + timeloss,
updated=updated
)
# Finally, update test data and flags
@@ -250,7 +260,8 @@ def update(request, user):
elo=elo,
passed=passed,
failed=failed,
finished=finished
finished=finished,
updated=updated
)
# Signal to stop completed tests
+1 -1
View File
@@ -149,7 +149,7 @@ def index(request, page=0, username=None, error=''):
def users(request):
# Build context dictionary for template
data = {'profiles' : Profile.objects.all()}
data = {'profiles' : Profile.objects.order_by('games')}
return render(request, 'users.html', data)
def viewUser(request, username):
+2
View File
@@ -8,6 +8,7 @@
<table class="datatable">
<tr>
<th>Username</th>
<th>Last Seen</th>
<th>Games</th>
<th>Tests</th>
<th>Repo</th>
@@ -17,6 +18,7 @@
{% for profile in profiles %}
<tr>
<td><a href="/viewUser/{{profile.user.username}}">{{profile.user.username}}</a></td>
<td>{{profile.updated|date:'Y-m-d H:i'}}</th>
<td class="numeric">{{profile.games}}</td>
<td class="numeric">{{profile.tests}}</td>
<td><a href="{{profile.repo}}">{{profile.repo}}</a></td>