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

store calculated quality per sas_id in activity

parent 776e6592
No related branches found
No related tags found
1 merge request!352Calcq in activity update
Pipeline #80176 failed
......@@ -76,10 +76,9 @@ def update_activity(task):
and improves overall performance
- to 'ARCHIVING, ARCHIVED, FINISHED' : check for incoming/existing 'archive' json from archiver
- to STORED : calculate quality
- to SCRUBBED, ARCHIVING, ARCHIVED, FINISHED : calculate ingested_fraction
- to _FAILED : calculate finished_fraction
- to STORED, PROCESSED, DISCARDED : check if all tasks are processed, set Activity to is_processed and AGGREGATE
- to (processed_statusses) : check if all tasks are processed, set Activity to is_processed and AGGREGATE
- always : determine if a task is in a 'verified' status
"""
......@@ -88,14 +87,6 @@ def update_activity(task):
activity = task.activity
# depending on the status transition, perform calculations
if task.status == State.STORED.value:
logger.info(f'- calculate_qualities')
# quality is calculated per task and per sas_id, reget the quality per sas_id
try:
activity.calculated_quality = task.calculated_qualities['per_sasid']
activity.save()
except:
pass
# calculate the fraction and list of statusses of ingested tasks of this SAS_ID
if task.status in [State.SCRUBBED.value, State.PRE_ARCHIVING.value, State.PRE_ARCHIVED.value,
......
......@@ -125,14 +125,9 @@ def calculate_qualities(task, tasks_for_this_sasid, quality_thresholds):
# store the result in task.calculated_qualities (not yet saved in the database)
qualities['per_sasid'] = calculated_quality_sasid
# save the new sas_id quality for all the other tasks (siblings) of this sas_id as well
for other_task in tasks_for_this_sasid:
# the task for which the quality is (re)calculated is saved later, but do save all its siblings
if other_task.id != task.id:
calc_q = other_task.calculated_qualities
calc_q['per_sasid'] = calculated_quality_sasid
other_task.calculated_qualities = calc_q
other_task.save()
# store the result in the activity, and save it
task.activity.calculated_quality = calculated_quality_sasid
task.activity.save()
except Exception as error:
logger.error(error)
......
......@@ -72,7 +72,7 @@ class TestCalculatedQualities(TestCase):
count = 0
tasks = Task.objects.all()
for task in tasks:
if task.calculated_qualities['per_sasid']:
if task.calculated_qualities['per_task']:
count += 1
self.assertEqual(count,6)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment