Basic result reporting ... no SPRT update yet, no time/crash logging
This commit is contained in:
1 parent
be2b9357d9
commit
40d316a6c8
5 files changed
+70
-6
No files matched your search
+19
-4
@@ -283,7 +283,21 @@ def reportNPS(data, nps):
|
|||||||
requests.post('{0}/submitNPS/'.format(SERVER), data=postdata)
|
requests.post('{0}/submitNPS/'.format(SERVER), data=postdata)
|
||||||
|
|
||||||
def reportResults(data, wins, losses, draws, crashes, timeloss):
|
def reportResults(data, wins, losses, draws, crashes, timeloss):
|
||||||
pass
|
|
||||||
|
# Server wants verification for reporting nps counts
|
||||||
|
postdata = {
|
||||||
|
'wins' : wins,
|
||||||
|
'losses' : losses,
|
||||||
|
'draws' : draws,
|
||||||
|
'crashes' : crashes,
|
||||||
|
'timeloss' : timeloss,
|
||||||
|
'username' : USERNAME,
|
||||||
|
'password' : PASSWORD,
|
||||||
|
'machineid' : data['machine']['id'],
|
||||||
|
'resultid' : data['result']['id'],
|
||||||
|
'testid' : data['test']['id']}
|
||||||
|
print (postdata)
|
||||||
|
requests.post('{0}/submitResults/'.format(SERVER), data=postdata)
|
||||||
|
|
||||||
def completeWorkload(data):
|
def completeWorkload(data):
|
||||||
|
|
||||||
@@ -347,12 +361,13 @@ def completeWorkload(data):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Batch result updates
|
# Batch result updates
|
||||||
if (sum(score) - sum(sent)) % 25 == 0 and score != sent:
|
if (sum(score) - sum(sent)) % 5 == 0 and score != sent:
|
||||||
wins = score[0] - sent[0]
|
wins = score[0] - sent[0]
|
||||||
losses = score[0] - sent[0]
|
losses = score[1] - sent[1]
|
||||||
draws = score[0] - sent[0]
|
draws = score[2] - sent[2]
|
||||||
reportResults(data, wins, losses, draws, crashes, timeloss)
|
reportResults(data, wins, losses, draws, crashes, timeloss)
|
||||||
crashes = timeloss = 0
|
crashes = timeloss = 0
|
||||||
|
sent = score[::]
|
||||||
|
|
||||||
# One final result send before we exit just in case
|
# One final result send before we exit just in case
|
||||||
wins = score[0] - sent[0]
|
wins = score[0] - sent[0]
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ class Result(Model):
|
|||||||
losses = IntegerField(default=0)
|
losses = IntegerField(default=0)
|
||||||
draws = IntegerField(default=0)
|
draws = IntegerField(default=0)
|
||||||
crashes = IntegerField(default=0)
|
crashes = IntegerField(default=0)
|
||||||
time = IntegerField(default=0)
|
timeloss = IntegerField(default=0)
|
||||||
updated = DateTimeField(auto_now=True)
|
updated = DateTimeField(auto_now=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import math, requests, random
|
import math, requests, random
|
||||||
|
|
||||||
|
from django.contrib.auth import authenticate
|
||||||
|
|
||||||
from OpenBench.config import *
|
from OpenBench.config import *
|
||||||
from OpenBench.models import Engine, Profile, Machine, Result, Test
|
from OpenBench.models import Engine, Profile, Machine, Result, Test
|
||||||
|
|
||||||
@@ -188,3 +190,46 @@ def workloadDictionary(machine, result, test):
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def update(request):
|
||||||
|
|
||||||
|
# Log the user in to verify
|
||||||
|
user = authenticate(
|
||||||
|
username=request.POST['username'],
|
||||||
|
password=request.POST['password'])
|
||||||
|
|
||||||
|
# Parse the data from the worker
|
||||||
|
wins = int(request.POST['wins'])
|
||||||
|
losses = int(request.POST['losses'])
|
||||||
|
draws = int(request.POST['draws'])
|
||||||
|
crashes = int(request.POST['crashes'])
|
||||||
|
timeloss = int(request.POST['timeloss'])
|
||||||
|
|
||||||
|
# Get each model to be updated
|
||||||
|
profile = Profile.objects.get(user=user)
|
||||||
|
machine = Machine.objects.get(id=int(request.POST['machineid']))
|
||||||
|
result = Result.objects.get(id=int(request.POST['resultid']))
|
||||||
|
test = Test.objects.get(id=int(request.POST['testid']))
|
||||||
|
|
||||||
|
# Update Profile
|
||||||
|
profile.games += wins + losses + draws
|
||||||
|
profile.save()
|
||||||
|
|
||||||
|
# Update Machine
|
||||||
|
machine.save()
|
||||||
|
|
||||||
|
# Update Result
|
||||||
|
result.games += wins + losses + draws
|
||||||
|
result.wins += wins
|
||||||
|
result.losses += losses
|
||||||
|
result.draws += draws
|
||||||
|
result.crashes += crashes
|
||||||
|
result.timeloss += timeloss
|
||||||
|
result.save()
|
||||||
|
|
||||||
|
# Update Test
|
||||||
|
test.games += wins + losses + draws
|
||||||
|
test.wins += wins
|
||||||
|
test.losses += losses
|
||||||
|
test.draws += draws
|
||||||
|
test.save()
|
||||||
+5
-1
@@ -423,5 +423,9 @@ def submitNPS(request):
|
|||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def submitResults(request):
|
def submitResults(request):
|
||||||
pass
|
|
||||||
|
|
||||||
|
# Try to update each location
|
||||||
|
OpenBench.utils.update(request)
|
||||||
|
#except: return HttpResponse('Stop')
|
||||||
|
|
||||||
|
return HttpResponse('None')
|
||||||
BIN
Binary file not shown.
Reference in new issue
Block a user