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

create a new aggregation task when the old one of a SAS_ID was discarded

parent 21322434
No related branches found
No related tags found
1 merge request!381Sdc 1607 bugfix discard repurpose aggregation
Pipeline #100058 failed
......@@ -228,7 +228,7 @@ def update_processed_and_aggregate(task):
if not ('fail' in activity.status):
# create a new 'aggregate_task' that is used to collect the aggregated output
# this has to be done only once, so this is a good place to do it.
if Task.objects.filter(sas_id=task.sas_id,task_type='aggregation').count()==0:
if Task.objects.filter(sas_id=task.sas_id,task_type='aggregation').exclude(status__icontains='discard').count()==0:
create_aggregation_task(task)
logger.info(f'- created aggregation task: {task.id}')
......@@ -329,6 +329,27 @@ def update_service_filter(task):
activity.service_filter = task.service_filter
activity.save()
def update_discard(task):
"""
when all tasks of this sas_id are discarded, then reset the activity
because the most probably usecase is that it will be used again by a new batch of tasks
"""
activity = task.activity
for t in Task.objects.filter(sas_id=task.sas_id,task_type='regular'):
if t.status not in [State.DISCARD.value,State.DISCARDED.value]:
return
# everything is DISCARDED
activity.project = None
activity.filter = None
activity.status = "reset"
activity.is_verified = False
activity.is_processed = False
activity.is_aggregated = False
activity.service_filter = None
activity.save()
def update_activity(task):
"""
......@@ -379,3 +400,6 @@ def update_activity(task):
# check if this activity has a 'service_filter', if not, use the one from the task
update_service_filter(task)
# if all tasks of this activity are discarded, then reset the activity
update_discard(task)
\ No newline at end of file
......@@ -51,11 +51,10 @@ class TaskTable(tables.Table):
class Meta:
model = Task
template_name = "django_tables2/bootstrap4.html"
fields = ("id", "type","WF","filter","service_filter","priority","status","quality","project","sas_id","resume","purge","actions","buttons")
fields = ("id", "task_type","WF","filter","service_filter","priority","status","quality","project","sas_id","resume","purge","actions","buttons")
# columns that need specific rendering
type = TypeColumn()
WF = WorkflowColumn()
#orkflowColumn()
status = StatusColumn()
purge = PurgeColumn()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment