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