Skip to content
Snippets Groups Projects
Commit 9809c5dd authored by Nico Vermaas's avatar Nico Vermaas
Browse files

extend get_size function with 'processed'

parent 4370e199
No related branches found
No related tags found
3 merge requests!95Dev nico,!93Master,!92extend get_size function with 'processed'
......@@ -17,7 +17,7 @@ DJANGO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
logger = logging.getLogger(__name__)
@timeit
def get_size(status_list):
def get_size(status_list, type):
"""
aggregate the sizes of all task with a status in the list
:param status_list: list of statuses to consider for the aggregation
......@@ -26,7 +26,11 @@ def get_size(status_list):
logger.info("get_size("+str(status_list)+")")
if type == 'processed':
field = 'size_processed'
else:
field = 'size_to_process'
query = field + '__sum'
tasks = Task.objects.filter(status__in=status_list)
sum_value = tasks.aggregate(Sum(field))[query]
......@@ -40,10 +44,11 @@ def convert_logentries_to_html(log_entries):
results = ""
try:
results += "<th>service</th><th>status</th><th>timestamp</th><th>cpu_cycles</th><th>wall_clock_time</th><th>logfile</th>"
results += "<th>service</th><th>step</th><th>status</th><th>timestamp</th><th>cpu_cycles</th><th>wall_clock_time</th><th>logfile</th>"
results += "<tbody>"
for log in log_entries:
line = "<tr><td><b>" + log.step_name + '</b></td>'
line = "<tr><td><b>" + str(log.service) + '</b></td>'
line += "<td><b>" + str(log.step_name) + '</b></td>'
line +='<td class="' + log.status + '" >' + log.status + "</td>"
try:
line += "<td>" + str(log.timestamp.strftime("%m-%d-%Y, %H:%M:%S")) + "</td>"
......
<a href="{% url 'task-details' record.pk 0 %}" class="btn btn-primary btn-sm" role="button"><i class="fas fa-list"></i> Details</a>&nbsp;
{% if record.resume %}
<a href="{% url 'task-hold-resume' record.pk 'hold' 0 %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-pause"></i> hold</a>
{% endif %}
{% if not record.resume %}
<a href="{% url 'task-hold-resume' record.pk 'resume' 0 %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-play"></i> start</a>
{% endif %}
\ No newline at end of file
......@@ -80,7 +80,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 1.0.0 (30 mar 2021 - 14:00)
<p class="footer"> Version 1.0.0 (1 apr 2021 - 12:00)
</div>
......
......@@ -54,8 +54,8 @@ urlpatterns = [
path('tasks/<int:pk>/setstatus/<new_status>/<page>', views.TaskSetStatus, name='task-setstatus-view'),
path('tasks/<int:pk>/setstatus/<new_status>', views.TaskSetStatus, name='task-details-setstatus'),
path('tasks/<int:pk>/change_priority/<priority_change>/<page>', views.TaskChangePriority, name='task-change-priority'),
path('tasks/<int:pk>/change_priority/<priority_change>', views.TaskChangePriority, name='task-change-priority'),
path('tasks/<int:pk>/change_priority/<priority_change>/<page>', views.ChangePriority, name='task-change-priority'),
path('tasks/<int:pk>/change_priority/<priority_change>', views.ChangePriority, name='task-change-priority'),
path('tasks/sort-tasks/<sort>', views.SortTasks, name='sort-tasks'),
......@@ -63,7 +63,7 @@ urlpatterns = [
path('tasks/set_active_filter', views.TaskSetActiveFilter, name='task-set-active-filter'),
path('tasks/task-set-onhold-filter/<onhold>', views.TaskSetOnHoldFilter, name='task-set-onhold-filter'),
path('tasks/<int:pk>/set_status/<new_status>/<page>', views.TaskSetStatusTables2, name = 'task-setstatus'),
path('tasks/set_status_multi/<new_status>', views.TaskSetStatusMultiTables2, name='task-multi-setstatus'),
path('tasks/set_status_multi/<new_status>', views.TaskSetStatusMulti, name='task-multi-setstatus'),
path('tasks/<int:pk>/hold/<hold_it>/<page>', views.Hold, name='task-hold-resume'),
......
......@@ -458,6 +458,11 @@ def Hold(request,pk,hold_it,page):
task = Task.objects.get(pk=pk)
task.resume = (hold_it == 'resume')
task.save()
if page==0:
# redirect to details screen
return redirect('/atdb/query')
else:
# redirect to tasks list
return redirect('/atdb/?page='+page)
@login_required
......@@ -495,7 +500,7 @@ def TaskSetOnHoldFilter(request, onhold):
@login_required
def TaskChangePriority(request,pk,priority_change,page=0):
def ChangePriority(request, pk, priority_change, page=0):
model = Task
task = Task.objects.get(pk=pk)
priority = task.priority + int(priority_change)
......@@ -529,7 +534,7 @@ def TaskSetStatusTables2(request,pk,new_status,page):
return redirect('/atdb/query/?page='+page)
@login_required
def TaskSetStatusMultiTables2(request,new_status):
def TaskSetStatusMulti(request, new_status):
# read the current querylist from the session
# yikes, this doesn't work if 2 users are simultaneously logged in
......@@ -562,7 +567,14 @@ class GetSizeView(generics.ListAPIView):
# if no 'status__in=' is given, then use the default list
status_list = settings.STATUSSES_WITH_DATA
size = algorithms.get_size(status_list)
try:
type = query_params['type'][0]
# should be 'processed' or 'to_process'
except:
# if no 'type=' is given, then use the default list
type = 'to_process'
size = algorithms.get_size(status_list, type)
# return a response
return Response({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment