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

Merge branch 'calcq-in-activity-update' into 'master'

Calcq in activity update

See merge request !352
parents 776e6592 e3de802a
No related branches found
No related tags found
1 merge request!352Calcq in activity update
Pipeline #85847 passed
......@@ -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)
......
......@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 26 Apr 2024
<p class="footer"> Version 27 May 2024
</div>
{% include 'taskdatabase/refresh.html' %}
......
......@@ -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)
......
......@@ -94,16 +94,6 @@ class TestUpdateActivity(TestCase):
self.assertEqual(actual, 12345)
def test_stored(self):
"""
test if the activity gets the calculated quality of the sas_id of the stored task
"""
activity = self.task1.activity
actual = activity.calculated_quality
self.assertEqual(actual, "good")
def test_scrubbed(self):
"""
test if the activity gets the ingested_fraction of 0 when scrubbed
......
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