Add test colouring, table headers, other visuals
This commit is contained in:
1 parent
290b729325
commit
fc1c3af9f1
8 files changed
+78
-46
No files matched your search
+2
-1
@@ -1,8 +1,9 @@
|
||||
from django.contrib import admin
|
||||
from OpenBench.models import LogEvent, Engine, Machine, Results, Test
|
||||
from OpenBench.models import LogEvent, Engine, Profile, Machine, Results, Test
|
||||
|
||||
admin.site.register(LogEvent)
|
||||
admin.site.register(Engine)
|
||||
admin.site.register(Profile)
|
||||
admin.site.register(Machine)
|
||||
admin.site.register(Results)
|
||||
admin.site.register(Test)
|
||||
+1
-1
@@ -29,7 +29,7 @@ class Profile(Model):
|
||||
user = OneToOneField(User, on_delete=CASCADE)
|
||||
games = IntegerField(default=0)
|
||||
tests = IntegerField(default=0)
|
||||
repo = CharField(max_length=256)
|
||||
repo = CharField(max_length=256, blank=True)
|
||||
enabled = BooleanField(default=False)
|
||||
approver = BooleanField(default=False)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
body {
|
||||
font-family: "Consolas";
|
||||
font-family: "Courier New";
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ table {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 1px solid black;
|
||||
tr {
|
||||
background-color: #DBDBDB;
|
||||
}
|
||||
|
||||
th {
|
||||
@@ -48,17 +48,14 @@ td {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
tr:nth-child(even){background-color: #DBDBDB}
|
||||
tr:nth-child(odd){background-color: #BDBDBD}
|
||||
.red:nth-child(even){background-color: #FAA5A5}
|
||||
.red:nth-child(odd){background-color: #FA8E8E}
|
||||
|
||||
.failed:nth-child(even){background-color: #FAA5A5}
|
||||
.failed:nth-child(odd){background-color: #FA8E8E}
|
||||
.green:nth-child(even){background-color: #2FFA62}
|
||||
.green:nth-child(odd){background-color: #9DF779}
|
||||
|
||||
.passed:nth-child(even){background-color: #2FFA62}
|
||||
.passed:nth-child(odd){background-color: #9DF779}
|
||||
|
||||
.active:nth-child(even){background-color: #E9FA32}
|
||||
.active:nth-child(odd){background-color: #EEF788}
|
||||
.yellow:nth-child(even){background-color: #E9FA32}
|
||||
.yellow:nth-child(odd){background-color: #EEF788}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
|
||||
@@ -5,32 +5,32 @@ from OpenBench.models import Test
|
||||
def oneDigitPrecision(value):
|
||||
try:
|
||||
value = round(value, 1)
|
||||
if "." not in str(value):
|
||||
return str(value) + ".0"
|
||||
pre, post = str(value).split(".")
|
||||
post += "0"
|
||||
return pre + "." + post[0:1]
|
||||
if '.' not in str(value):
|
||||
return str(value) + '.0'
|
||||
pre, post = str(value).split('.')
|
||||
post += '0'
|
||||
return pre + '.' + post[0:1]
|
||||
except:
|
||||
return value
|
||||
|
||||
def twoDigitPrecision(value):
|
||||
try:
|
||||
value = round(value, 2)
|
||||
if "." not in str(value):
|
||||
return str(value) + ".00"
|
||||
pre, post = str(value).split(".")
|
||||
post += "00"
|
||||
return pre + "." + post[0:2]
|
||||
if '.' not in str(value):
|
||||
return str(value) + '.00'
|
||||
pre, post = str(value).split('.')
|
||||
post += '00'
|
||||
return pre + '.' + post[0:2]
|
||||
except:
|
||||
return value
|
||||
|
||||
def gitDiffLink(test):
|
||||
|
||||
if type(test) != Test:
|
||||
dev = test["dev"]["source"]
|
||||
base = test["base"]["source"]
|
||||
devsha = test["dev"]["sha"]
|
||||
basesha = test["base"]["sha"]
|
||||
dev = test['dev']['source']
|
||||
base = test['base']['source']
|
||||
devsha = test['dev']['sha']
|
||||
basesha = test['base']['sha']
|
||||
|
||||
else:
|
||||
dev = test.dev.source
|
||||
@@ -38,15 +38,15 @@ def gitDiffLink(test):
|
||||
devsha = test.dev.sha
|
||||
basesha = test.base.sha
|
||||
|
||||
repo = "/".join(dev.split("/")[:-2])
|
||||
repo = '/'.join(dev.split('/')[:-2])
|
||||
|
||||
return "{0}/compare/{1}...{2}".format(repo, basesha[:8], devsha[:8])
|
||||
return '{0}/compare/{1}...{2}'.format(repo, basesha[:8], devsha[:8])
|
||||
|
||||
def statParagraph(test):
|
||||
|
||||
tokens = test.devoptions.split(" ")
|
||||
threads = tokens[0].split("=")[1]
|
||||
hash = tokens[1].split("=")[1]
|
||||
tokens = test.devoptions.split(' ')
|
||||
threads = tokens[0].split('=')[1]
|
||||
hash = tokens[1].split('=')[1]
|
||||
|
||||
lowerllr = twoDigitPrecision(test.lowerllr)
|
||||
currentllr = twoDigitPrecision(test.currentllr)
|
||||
@@ -54,13 +54,22 @@ def statParagraph(test):
|
||||
elolower = twoDigitPrecision(test.elolower)
|
||||
eloupper = twoDigitPrecision(test.eloupper)
|
||||
|
||||
return "SPRT @ {0}s Threads={1} Hash={2}MB<br>".format(test.timecontrol, threads, hash) \
|
||||
+ "LLR: {0} ({1}, {2}) [{3}, {4}]<br>".format(lowerllr, currentllr, upperllr, elolower, eloupper) \
|
||||
+ "Games: {0} W: {1} L: {2} D: {3}".format(test.games, test.wins, test.losses, test.draws)
|
||||
return 'SPRT @ {0}s Threads={1} Hash={2}MB<br>'.format(test.timecontrol, threads, hash) \
|
||||
+ 'LLR: {0} ({1}, {2}) [{3}, {4}]<br>'.format(lowerllr, currentllr, upperllr, elolower, eloupper) \
|
||||
+ 'Games: {0} W: {1} L: {2} D: {3}'.format(test.games, test.wins, test.losses, test.draws)
|
||||
|
||||
def testResultColour(test):
|
||||
|
||||
if test.passed: return 'green'
|
||||
if test.failed:
|
||||
if test.elo >= 0: return 'yellow'
|
||||
return 'red'
|
||||
return ''
|
||||
|
||||
register = template.Library()
|
||||
register.filter("oneDigitPrecision", oneDigitPrecision)
|
||||
register.filter("twoDigitPrecision", twoDigitPrecision)
|
||||
register.filter("gitDiffLink", gitDiffLink)
|
||||
register.filter("statParagraph", statParagraph)
|
||||
register.filter('oneDigitPrecision', oneDigitPrecision)
|
||||
register.filter('twoDigitPrecision', twoDigitPrecision)
|
||||
register.filter('gitDiffLink', gitDiffLink)
|
||||
register.filter('statParagraph', statParagraph)
|
||||
register.filter('testResultColour', testResultColour)
|
||||
|
||||
+2
-3
@@ -129,7 +129,7 @@ def machines(request):
|
||||
def eventLog(request):
|
||||
|
||||
# Build context dictionary for template
|
||||
data = {'events': LogEvent.objects.all()}
|
||||
data = {'events': LogEvent.objects.all().order_by('-id')[:50]}
|
||||
return render(request, 'eventLog.html', data)
|
||||
|
||||
@login_required
|
||||
@@ -140,7 +140,6 @@ def newTest(request):
|
||||
return render(request, 'newTest.html', {"user" : request.user})
|
||||
|
||||
try:
|
||||
|
||||
# Throw out non-approved / disabled users
|
||||
profile = Profile.objects.get(user=request.user)
|
||||
if not profile.enabled:
|
||||
@@ -151,7 +150,7 @@ def newTest(request):
|
||||
|
||||
# Log the test creation
|
||||
event = LogEvent()
|
||||
event.data = 'Created Test {0} ({1})'.format(str(test), test.id)
|
||||
event.data = 'Created test {0} ({1})'.format(str(test), test.id)
|
||||
event.author = request.user.username
|
||||
event.save()
|
||||
|
||||
|
||||
Reference in new issue
Block a user