Add worker information to main page

This commit is contained in:
AndyGrant committed 2018-06-25 21:12:25 -04:00
1 parent c4e80c3008
commit bd98e33fcd
2 files changed
+19 -5

No files matched your search

+16 -2
View File
@@ -126,6 +126,19 @@ def index(request, page=0, pageLength=50, username=None, error=''):
completed = completed.exclude(deleted=True) completed = completed.exclude(deleted=True)
completed = completed.order_by('-updated') 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 # Index is wrapped just to view one user
if username != None: if username != None:
pending = pending.filter(author=username) 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 # Build context dictionary for index template
data = { data = {
'error' : error,
'pending' : pending, 'pending' : pending,
'active' : active, 'active' : active,
'completed' : completed[start:end], 'completed' : completed[start:end],
'error' : error, 'status' : workerData,
'paging' : paging, 'paging' : paging,
} }
@@ -168,7 +182,7 @@ def viewUser(request, username, page=0):
def machines(request): def machines(request):
# Build context dictionary for machine template with machines updated recently # 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)} data = {'machines' : Machine.objects.filter(updated__gte=target)}
return render(request, 'machines.html', data) return render(request, 'machines.html', data)
+3 -3
View File
@@ -3,7 +3,7 @@
{% block content %} {% block content %}
<table class="datatable"> <table class="datatable">
{% if paging.page == 0 %} {% 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 %} {% if pending %}
<tr> <tr>
<th>Engine</th> <th>Engine</th>
@@ -26,7 +26,7 @@
<td class="statblock"><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td> <td class="statblock"><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
</tr> </tr>
{% endfor %} {% 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 %} {% if active %}
<tr> <tr>
<th>Engine</th> <th>Engine</th>
@@ -50,7 +50,7 @@
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% 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 %} {% if completed %}
<tr> <tr>
<th>Engine</th> <th>Engine</th>