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

Merge branch 'master' into 'dev-nico'

SDC-470: Create api-function to retrieve the minimum start time and maximum...

See merge request !158
parents f534410b 3df884ac
No related branches found
No related tags found
4 merge requests!163SDC-470: Create api-function to retrieve the minimum start time and maximum...,!160Master,!159Dev nico,!158SDC-470: Create api-function to retrieve the minimum start time and maximum...
......@@ -30,6 +30,11 @@ These diagrams show the current implementation and are kept up-to-date.
![](atdb/docs/ATDB-LDV%20Workflow%20Diagram.png)
### GUI implementation
* https://app.diagrams.net/#G16R8L06OFiKHFHBUA6FhrNVZVAaQBC2tU
![](atdb/docs/ATDB-LDV%20GUI.png)
## Deployed Instances
### main GUI:
......@@ -119,7 +124,7 @@ This is the procedure for that.
- when automatic build is finished, push >> to deploy
on 'test', 'acc' and 'prod' machine's:
on 'test' (sdc@dop814), 'acc' (sdc@dop457) and 'prod' (sdco@dop821) machine's:
> docker exec -it atdb-ldv python manage.py makemigrations --settings atdb.settings.docker_sdc
(this should say 'No changes detected', but do this step anyway as a check)
......
......@@ -41,6 +41,34 @@ def get_size(status_list, type):
return sum_value
@timeit
def get_min_start_and_max_end_time(sas_id):
"""
Retrieve the minimum start time en maximum end time of a set of taskids (sas_id) which has the
status 'archived' or 'finished'
The start time is the moment when the task start 'processing'
The end time is the moment when the task was 'processed'
"""
min_start_time = None
max_end_time = None
logger.info("get_min_start_and_max_end_time(" + str(sas_id) + ")")
tasks = Task.objects.filter(sas_id=sas_id).filter(status='archived') + Task.objects.filter(sas_id=sas_id).filter(status='finished')
for task in tasks:
# If more entrees are found for 'processing' task, get the latest
start_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processing').lastest('timestamp').timestamp
# If more entrees are found for 'processed' task, get the latest
end_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processed').lastest('timestamp').timestamp
if min_start_time is None:
min_start_time = start_time
elif start_time < min_start_time:
min_start_time = start_time
if max_end_time is None:
max_end_time = end_time
elif end_time > max_end_time:
max_end_time = end_time
return min_start_time, max_end_time
def convert_logentries_to_html(log_entries):
results = ""
......
......@@ -80,7 +80,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 1.0.0 (18 jan 2021 - 15:00)
<p class="footer"> Version 1.0.0 (21 jan 2021 - 19:00)
</div>
......
......@@ -54,6 +54,8 @@ urlpatterns = [
# --- custom requests ---
# /atdb/get_size?status__in=defined,staged
path('tasks/get_size/', views.GetSizeView.as_view(), name='get-size-view'),
# /atdb/get_min_start_and_max_end_time?sas_id=65005
path('get_min_start_and_max_end_time/', views.GetMinMaxTimeView.as_view(), name='get-min-start-and-max-end-time-view'),
# --- controller resources ---
path('tasks/<int:pk>/setstatus/<new_status>/<page>', views.TaskSetStatus, name='task-setstatus-view'),
......
......@@ -737,3 +737,22 @@ class GetSizeView(generics.ListAPIView):
})
# /atdb/get_min_start_and_max_end_time?sas_id=650065
class GetMinMaxTimeView(generics.ListAPIView):
queryset = Task.objects.all()
# override list and generate a custom response
def list(self, request, *args, **kwargs):
# read the arguments from the query
try:
sas_id = self.request.query_params['sas_id']
start_time, end_time = algorithms.get_min_start_and_max_end_time(sas_id)
return Response({
'start_time': start_time,
'end_time': end_time,
})
except Exception as error:
return Response({
'error': str(error)
})
\ No newline at end of file
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