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): ...@@ -21,7 +21,7 @@ class Workflow(models.Model):
class Task(models.Model): class Task(models.Model):
# Task control properties # 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) filter = models.CharField(max_length=30, blank=True, null=True)
new_status = models.CharField(max_length=50, default="defining", 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) 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): ...@@ -33,7 +33,7 @@ def get_size(status_list, type):
field = 'size_to_process' field = 'size_to_process'
query = field + '__sum' 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] sum_value = tasks.aggregate(Sum(field))[query]
if sum_value == None: if sum_value == None:
...@@ -175,7 +175,7 @@ def aggregate_resources_tasks(selection): ...@@ -175,7 +175,7 @@ def aggregate_resources_tasks(selection):
# get all active tasks # get all active tasks
if 'active' in selection: 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 # retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct() active_workflows = active_tasks.values('workflow').distinct()
...@@ -198,7 +198,7 @@ def aggregate_resources_tasks(selection): ...@@ -198,7 +198,7 @@ def aggregate_resources_tasks(selection):
# get the numbers for this workflow # get the numbers for this workflow
# all tasks for this workflow for the 'grand total' # 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() nr_of_tasks_per_workflow = tasks_per_workflow.count()
sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process')) sum_size_to_process = tasks_per_workflow.aggregate(Sum('size_to_process'))
...@@ -244,7 +244,7 @@ def aggregate_resources_logs(selection): ...@@ -244,7 +244,7 @@ def aggregate_resources_logs(selection):
# get all active tasks # get all active tasks
if 'active' in selection: 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 # retrieve all unique workflows from the active tasks
active_workflows = active_tasks.values('workflow').distinct() active_workflows = active_tasks.values('workflow').distinct()
...@@ -294,7 +294,7 @@ def aggregate_resources_logs_version1(): ...@@ -294,7 +294,7 @@ def aggregate_resources_logs_version1():
records = [] records = []
# get all active tasks # 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() active_tasks_count = active_tasks.count()
# retrieve all unique workflows # retrieve all unique workflows
...@@ -333,7 +333,7 @@ def aggregate_resources_logs_version1(): ...@@ -333,7 +333,7 @@ def aggregate_resources_logs_version1():
def construct_link_to_tasks_api(request, status, workflow_id, count): def construct_link_to_tasks_api(request, status, workflow_id, count):
link = str(count) link = str(count)
try: try:
if status in settings.ACTIVE_STATUSSES: if status in settings.ALL_STATUSSES:
query = "?status=" + status + "&workflow__id=" + str(workflow_id) query = "?status=" + status + "&workflow__id=" + str(workflow_id)
else: else:
if 'failed' in status: if 'failed' in status:
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</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> </div>
......
...@@ -33,6 +33,8 @@ urlpatterns = [ ...@@ -33,6 +33,8 @@ urlpatterns = [
path('tasks/<int:pk>/', views.TaskDetailsViewAPI.as_view(), name='task-detail-view-api'), 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/', views.TaskListViewAPIFast.as_view(), name='tasks-api-fast'),
path('tasks-fast/<int:pk>/', views.TaskDetailsViewAPIFast.as_view(), name='task-detail-view-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/', views.WorkflowListViewAPI.as_view(), name='workflows-api'),
path('workflows/<int:pk>/', views.WorkflowDetailsViewAPI.as_view(), name='workflow-detail-view-api'), path('workflows/<int:pk>/', views.WorkflowDetailsViewAPI.as_view(), name='workflow-detail-view-api'),
......
...@@ -46,6 +46,7 @@ class TaskFilter(filters.FilterSet): ...@@ -46,6 +46,7 @@ class TaskFilter(filters.FilterSet):
model = Task model = Task
fields = { fields = {
'task_type': ['exact', 'icontains', 'in'],
'creationTime': ['icontains'], 'creationTime': ['icontains'],
'filter': ['exact', 'icontains'], 'filter': ['exact', 'icontains'],
'workflow__id' : ['exact', 'icontains'], 'workflow__id' : ['exact', 'icontains'],
...@@ -68,6 +69,7 @@ class TaskFilterQueryPage(filters.FilterSet): ...@@ -68,6 +69,7 @@ class TaskFilterQueryPage(filters.FilterSet):
fields = { fields = {
'id': ['exact', 'gte', 'lte'], 'id': ['exact', 'gte', 'lte'],
#'task_type': ['exact','in'],
'workflow__id': ['exact'], 'workflow__id': ['exact'],
'filter': ['exact', 'icontains'], 'filter': ['exact', 'icontains'],
'priority': ['exact', 'gte', 'lte'], 'priority': ['exact', 'gte', 'lte'],
...@@ -140,6 +142,7 @@ class PostProcessingFilter(filters.FilterSet): ...@@ -140,6 +142,7 @@ class PostProcessingFilter(filters.FilterSet):
class QueryView(SingleTableMixin, FilterView): class QueryView(SingleTableMixin, FilterView):
table_class = TaskTable table_class = TaskTable
model = Task model = Task
queryset = Task.objects.filter(task_type='regular')
template_name = "query/index.html" template_name = "query/index.html"
filterset_class = TaskFilterQueryPage filterset_class = TaskFilterQueryPage
...@@ -204,6 +207,9 @@ class IndexView(ListView): ...@@ -204,6 +207,9 @@ class IndexView(ListView):
if (search_box is not None): if (search_box is not None):
tasks = get_searched_tasks(search_box, sort) 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 paginator = Paginator(tasks, config.TASKS_PER_PAGE) # Show 50 tasks per page
page = self.request.GET.get('page') page = self.request.GET.get('page')
...@@ -226,9 +232,6 @@ class IndexView(ListView): ...@@ -226,9 +232,6 @@ class IndexView(ListView):
return tasks 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): def get_searched_tasks(search, sort):
tasks = Task.objects.filter( tasks = Task.objects.filter(
...@@ -329,7 +332,46 @@ class DiagramView(ListView): ...@@ -329,7 +332,46 @@ class DiagramView(ListView):
# ---------- REST API views ----------- # ---------- REST API views -----------
# example: /atdb/tasks/ # 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): 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. A pagination list of tasks, unsorted.
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment