Add worker information to main page
This commit is contained in:
1 parent
c4e80c3008
commit
bd98e33fcd
2 files changed
+19
-5
No files matched your search
+16
-2
@@ -126,6 +126,19 @@ def index(request, page=0, pageLength=50, username=None, error=''):
|
||||
completed = completed.exclude(deleted=True)
|
||||
completed = completed.order_by('-updated')
|
||||
|
||||
# Pull data from active machines
|
||||
target = datetime.datetime.utcnow().replace(tzinfo=utc) - datetime.timedelta(minutes=10)
|
||||
machines = Machine.objects.filter(updated__gte=target)
|
||||
if username != None: machines.filter(owner=username)
|
||||
|
||||
# Extract stat information from workers
|
||||
machineCount = len(machines)
|
||||
threadCount = sum(machine.threads for machine in machines)
|
||||
npsTotal = sum(machine.threads * machine.mnps for machine in machines)
|
||||
workerData = "{0} Machines {1} Threads {2} MNPS".format(
|
||||
machineCount, threadCount, round(npsTotal, 2)
|
||||
)
|
||||
|
||||
# Index is wrapped just to view one user
|
||||
if username != None:
|
||||
pending = pending.filter(author=username)
|
||||
@@ -145,10 +158,11 @@ def index(request, page=0, pageLength=50, username=None, error=''):
|
||||
|
||||
# Build context dictionary for index template
|
||||
data = {
|
||||
'error' : error,
|
||||
'pending' : pending,
|
||||
'active' : active,
|
||||
'completed' : completed[start:end],
|
||||
'error' : error,
|
||||
'status' : workerData,
|
||||
'paging' : paging,
|
||||
}
|
||||
|
||||
@@ -168,7 +182,7 @@ def viewUser(request, username, page=0):
|
||||
def machines(request):
|
||||
|
||||
# Build context dictionary for machine template with machines updated recently
|
||||
target = datetime.datetime.utcnow().replace(tzinfo=utc) - datetime.timedelta(minutes=20)
|
||||
target = datetime.datetime.utcnow().replace(tzinfo=utc) - datetime.timedelta(minutes=10)
|
||||
data = {'machines' : Machine.objects.filter(updated__gte=target)}
|
||||
return render(request, 'machines.html', data)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% block content %}
|
||||
<table class="datatable">
|
||||
{% if paging.page == 0 %}
|
||||
<tr><td class="embedded" colspan='5'><h2>Pending</h2></td></tr>
|
||||
<tr><td class="embedded" colspan='7'><h2>Pending</h2></td></tr>
|
||||
{% if pending %}
|
||||
<tr>
|
||||
<th>Engine</th>
|
||||
@@ -26,7 +26,7 @@
|
||||
<td class="statblock"><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr><td class="embedded" colspan='5'><h2>Active</h2></td></tr>
|
||||
<tr><td class="embedded" colspan='7'><h2>Active - {{status}}</h2></td></tr>
|
||||
{% if active %}
|
||||
<tr>
|
||||
<th>Engine</th>
|
||||
@@ -50,7 +50,7 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<tr><td class="embedded" colspan='5'><h2>Finished</h2></td></tr>
|
||||
<tr><td class="embedded" colspan='7'><h2>Finished</h2></td></tr>
|
||||
{% if completed %}
|
||||
<tr>
|
||||
<th>Engine</th>
|
||||
|
||||
Reference in new issue
Block a user