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

adding get_size endpoint

parent 472e8078
No related branches found
No related tags found
No related merge requests found
Pipeline #8741 passed
atdb/docs/ATDB-LDV Workflow Diagram.png

102 KiB | W: | H:

atdb/docs/ATDB-LDV Workflow Diagram.png

107 KiB | W: | H:

atdb/docs/ATDB-LDV Workflow Diagram.png
atdb/docs/ATDB-LDV Workflow Diagram.png
atdb/docs/ATDB-LDV Workflow Diagram.png
atdb/docs/ATDB-LDV Workflow Diagram.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -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'
)
......
......@@ -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
......
......@@ -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,
......
......@@ -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>
......
......@@ -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,
})
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