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

Merge branch 'dev-nico' into 'master'

Dev nico

See merge request !151
parents ff793726 5387c9fb
No related branches found
No related tags found
4 merge requests!158SDC-470: Create api-function to retrieve the minimum start time and maximum...,!153Release datamodel for postprocessing changes,!152add PostProcessingRule object to database,!151Dev nico
Pipeline #23737 passed
......@@ -21,7 +21,7 @@ class Workflow(models.Model):
class Task(models.Model):
# Task control properties
task_type = models.CharField(max_length=20, default="task")
task_type = models.CharField(max_length=20, default="regular")
filter = models.CharField(max_length=30, blank=True, null=True)
new_status = models.CharField(max_length=50, default="defining", null=True)
status = models.CharField(db_index=True, default="unknown", max_length=50,blank=True, null=True)
......
......@@ -33,7 +33,7 @@ def get_size(status_list, type):
field = 'size_to_process'
query = field + '__sum'
tasks = Task.objects.filter(status__in=status_list)
tasks = Task.objects.filter(status__in=status_list).filter(task_type='regular')
sum_value = tasks.aggregate(Sum(field))[query]
if sum_value == None:
......@@ -175,7 +175,7 @@ def aggregate_resources_tasks(selection):
# get all active tasks
if 'active' in selection:
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES).filter(task_type='regular')
# retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct()
......@@ -198,7 +198,7 @@ def aggregate_resources_tasks(selection):
# get the numbers for this workflow
# all tasks for this workflow for the 'grand total'
tasks_per_workflow = Task.objects.filter(workflow=workflow)
tasks_per_workflow = Task.objects.filter(workflow=workflow).filter(task_type='regular')
nr_of_tasks_per_workflow = tasks_per_workflow.count()
sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process'))
......@@ -244,7 +244,7 @@ def aggregate_resources_logs(selection):
# get all active tasks
if 'active' in selection:
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES).filter(task_type='regular')
# retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct()
......@@ -294,7 +294,7 @@ def aggregate_resources_logs_version1():
records = []
# get all active tasks
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES)
active_tasks = Task.objects.filter(status__in=settings.ACTIVE_STATUSSES).filter(task_type='regular')
active_tasks_count = active_tasks.count()
# retrieve all unique workflows
......@@ -333,7 +333,7 @@ def aggregate_resources_logs_version1():
def construct_link_to_tasks_api(request, status, workflow_id, count):
link = str(count)
try:
if status in settings.ACTIVE_STATUSSES:
if status in settings.ALL_STATUSSES:
query = "?status=" + status + "&workflow__id=" + str(workflow_id)
else:
if 'failed' in status:
......
......@@ -80,7 +80,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 1.0.0 (17 jan 2021 - 15:00)
<p class="footer"> Version 1.0.0 (18 jan 2021 - 15:00)
</div>
......
......@@ -33,6 +33,8 @@ urlpatterns = [
path('tasks/<int:pk>/', views.TaskDetailsViewAPI.as_view(), name='task-detail-view-api'),
path('tasks-fast/', views.TaskListViewAPIFast.as_view(), name='tasks-api-fast'),
path('tasks-fast/<int:pk>/', views.TaskDetailsViewAPIFast.as_view(), name='task-detail-view-api-fast'),
path('postprocessing-tasks/', views.PostProcessingTaskListViewAPI.as_view(), name='postprocessing-tasks-api'),
path('all-tasks/', views.AllTaskListViewAPI.as_view(), name='all-tasks-api'),
path('workflows/', views.WorkflowListViewAPI.as_view(), name='workflows-api'),
path('workflows/<int:pk>/', views.WorkflowDetailsViewAPI.as_view(), name='workflow-detail-view-api'),
......
......@@ -46,6 +46,7 @@ class TaskFilter(filters.FilterSet):
model = Task
fields = {
'task_type': ['exact', 'icontains', 'in'],
'creationTime': ['icontains'],
'filter': ['exact', 'icontains'],
'workflow__id' : ['exact', 'icontains'],
......@@ -68,6 +69,7 @@ class TaskFilterQueryPage(filters.FilterSet):
fields = {
'id': ['exact', 'gte', 'lte'],
#'task_type': ['exact','in'],
'workflow__id': ['exact'],
'filter': ['exact', 'icontains'],
'priority': ['exact', 'gte', 'lte'],
......@@ -140,6 +142,7 @@ class PostProcessingFilter(filters.FilterSet):
class QueryView(SingleTableMixin, FilterView):
table_class = TaskTable
model = Task
queryset = Task.objects.filter(task_type='regular')
template_name = "query/index.html"
filterset_class = TaskFilterQueryPage
......@@ -204,6 +207,9 @@ class IndexView(ListView):
if (search_box is not None):
tasks = get_searched_tasks(search_box, sort)
# only return the 'regular' tasks, and not the 'postprocessing' tasks in the GUI
tasks = tasks.filter(task_type='regular')
paginator = Paginator(tasks, config.TASKS_PER_PAGE) # Show 50 tasks per page
page = self.request.GET.get('page')
......@@ -226,9 +232,6 @@ class IndexView(ListView):
return tasks
def get_searched_tasks_only_status(search, sort):
tasks = Task.objects.filter(status__in=search).order_by(sort)
return tasks
def get_searched_tasks(search, sort):
tasks = Task.objects.filter(
......@@ -329,7 +332,46 @@ class DiagramView(ListView):
# ---------- REST API views -----------
# example: /atdb/tasks/
# this shows only 'regular' tasks and not 'postprocessing' tasks
# the endpoint it kept 'tasks' for backward compatibility reasons.
class TaskListViewAPI(generics.ListCreateAPIView):
"""
A pagination list of tasks, unsorted.
"""
model = Task
queryset = Task.objects.filter(task_type='regular').order_by('-priority','id')
#serializer_class = TaskSerializer
# using the Django Filter Backend - https://django-filter.readthedocs.io/en/latest/index.html
filter_backends = (filters.DjangoFilterBackend,)
filter_class = TaskFilter
def get_serializer_class(self):
if self.request.method in ['GET']:
return TaskReadSerializer
else:
return TaskWriteSerializer
class PostProcessingTaskListViewAPI(generics.ListCreateAPIView):
"""
A pagination list of tasks, unsorted.
"""
model = Task
queryset = Task.objects.filter(task_type='postprocessing').order_by('-priority','id')
#serializer_class = TaskSerializer
# using the Django Filter Backend - https://django-filter.readthedocs.io/en/latest/index.html
filter_backends = (filters.DjangoFilterBackend,)
filter_class = TaskFilter
def get_serializer_class(self):
if self.request.method in ['GET']:
return TaskReadSerializer
else:
return TaskWriteSerializer
# all tasks
class AllTaskListViewAPI(generics.ListCreateAPIView):
"""
A pagination list of tasks, unsorted.
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment