Skip to content
Snippets Groups Projects
Commit 08f73d1f authored by Roy de Goei's avatar Roy de Goei
Browse files

SDC-470: Do not filter on status and skip when no timestamp

parent 19aeaa8a
No related branches found
No related tags found
2 merge requests!170Master,!168SDC-470: Do not filter on status and skip when no timestamp
......@@ -44,30 +44,33 @@ def get_size(status_list, type):
@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'
Retrieve the minimum start time en maximum end time of a set of taskids (sas_id)
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(Q(status='archived') | Q(status='finished'))
tasks = Task.objects.filter(sas_id=sas_id)
for task in tasks:
# If more entrees are found for 'processing' task, get the latest
latest_start_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processing').latest('timestamp')
start_time = latest_start_time.timestamp
# If more entrees are found for 'processed' task, get the latest
lastest_end_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processed').latest('timestamp')
end_time = lastest_end_time.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
try:
# If more entrees are found for 'processing' task, get the latest
latest_start_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processing').latest('timestamp')
start_time = latest_start_time.timestamp
# If more entrees are found for 'processed' task, get the latest
lastest_end_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processed').latest('timestamp')
end_time = lastest_end_time.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
except:
pass # having no timestamp, just skip
return min_start_time, max_end_time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment