diff --git a/atdb/docs/ATDB-LDV Workflow Diagram.png b/atdb/docs/ATDB-LDV Workflow Diagram.png index dead107079db4568e4d5d882a2c5984b3599b8b8..6270f313264969080d2adadfe8d2017f011f47c6 100644 Binary files a/atdb/docs/ATDB-LDV Workflow Diagram.png and b/atdb/docs/ATDB-LDV Workflow Diagram.png differ diff --git a/atdb/taskdatabase/serializers.py b/atdb/taskdatabase/serializers.py index 47e8a14a8393787c73b353a1d71e23bcb035968e..1710ee3780aa4056f4a8f3190d2126a6ee0792bb 100644 --- a/atdb/taskdatabase/serializers.py +++ b/atdb/taskdatabase/serializers.py @@ -52,6 +52,7 @@ class TaskWriteSerializer(serializers.ModelSerializer): 'stage_request_id', 'status','new_status', 'inputs','outputs','metrics','status_history', + 'size_to_process','size_processed','total_processing_time', 'log_entries' ) @@ -104,6 +105,7 @@ class TaskReadSerializer(serializers.ModelSerializer): 'stage_request_id', 'status','new_status', 'inputs','outputs','metrics','status_history', + 'size_to_process', 'size_processed', 'total_processing_time', 'log_entries' ) diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 76f98a9077f23a80b1b1896a6c30df0f99c54b9b..c28e8c707f1f8b9af866e2ba15778d81ec831a84 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -5,7 +5,7 @@ Description: Business logic for ATDB. These functions are called from the views (views.py). """ -from django.db.models import Sum +from django.db.models import Q,Sum import logging from .common import timeit from ..models import Task @@ -24,11 +24,13 @@ def get_size(status_list): :return: summed sizes """ - logger.info("get_size("+status_list+")") - #todo: implement + logger.info("get_size("+str(status_list)+")") + field = 'size_to_process' query = field + '__sum' - sum_value = Task.objects.filter(status__in=status_list).aggregate(Sum(field))[query] + tasks = Task.objects.filter(status__in=status_list) + sum_value = tasks.aggregate(Sum(field))[query] + if sum_value == None: sum_value = 0.0 return sum_value diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 1dbae9b85eb2677beda3eaf77f353b38be35a4be..36aa3d9640f9c90869aeb9372103f9a6e3d1b773 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -24,7 +24,7 @@ <th width="15%">Workflow</th> <th>Created</th> - <th>Size</th> + <th>size-to-process</th> <th>Set Status</th> </tr> </thead> @@ -44,7 +44,7 @@ </div> {% include 'taskdatabase/pagination.html' %} </div> - <p class="footer"> Version 1.0.0 (2 feb 2021 - 10:00) + <p class="footer"> Version 1.0.0 (2 feb 2021 - 12:00) <script type="text/javascript"> (function(seconds) { var refresh, diff --git a/atdb/taskdatabase/templates/taskdatabase/tasks.html b/atdb/taskdatabase/templates/taskdatabase/tasks.html index 871913307a1cbbb65e29fa160b6578c32b3c0555..5e668b238fb4e11bd4305a5a7b5364c018e26fad 100644 --- a/atdb/taskdatabase/templates/taskdatabase/tasks.html +++ b/atdb/taskdatabase/templates/taskdatabase/tasks.html @@ -14,7 +14,7 @@ <td>{{ task.workflow }} <td>{{ task.creationTime|date:"Y-m-d H:i:s" }} </td> - <td>{{ task.size|filesizeformat }} </td> + <td>{{ task.size_to_process|filesizeformat }} </td> </td> <td> diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index c913519aa2c6e399926682abc7934f28180ba6a2..5acba9afc56067deaa1003e0dc44e2ae20e2f8ec 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -28,7 +28,7 @@ class TaskFilter(filters.FilterSet): model = Task fields = { - 'task_type': ['exact', 'icontains'], + 'task_type': ['exact', 'icontains','in'], 'filter': ['exact', 'icontains'], 'project': ['exact', 'icontains'], 'sas_id': ['exact', 'icontains'], @@ -239,13 +239,20 @@ class GetSizeView(generics.ListAPIView): # override list and generate a custom response def list(self, request, *args, **kwargs): - # call the business logic - status_list = ['defined','staged'] + query_params = dict(self.request.query_params) + try: + status_in = query_params['status__in'] + status_list=status_in[0].split(',') + print(status_list) + except: + # if no 'status__in=' is given, then use the default list + status_list = ['staged','processing','processed','validating','validate', 'ingesting', 'removing', 'removed'] + size = algorithms.get_size(status_list) # return a response return Response({ - 'size': size, + 'total_size': size, })