From 80488336a5b9699e5ebcbff521d3155492579426 Mon Sep 17 00:00:00 2001 From: Vermaas <vermaas@astron.nl> Date: Fri, 12 Jan 2024 14:12:44 +0100 Subject: [PATCH] bugfix (encore) --- atdb/atdb/settings/dev.py | 2 +- atdb/taskdatabase/services/calculated_qualities.py | 9 +++++++++ atdb/taskdatabase/templates/taskdatabase/index.html | 2 +- atdb/taskdatabase/tests/test_calculated_qualities.py | 5 +++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/atdb/atdb/settings/dev.py b/atdb/atdb/settings/dev.py index dc1cae90..32433ae2 100644 --- a/atdb/atdb/settings/dev.py +++ b/atdb/atdb/settings/dev.py @@ -13,7 +13,7 @@ DATABASES = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'USER': 'atdb_admin', 'PASSWORD': 'atdb123', - 'NAME': 'atdb_ldv_4jan2024', + 'NAME': 'atdb_ldv_12jan2024', 'HOST': 'localhost', 'PORT': '5432', }, diff --git a/atdb/taskdatabase/services/calculated_qualities.py b/atdb/taskdatabase/services/calculated_qualities.py index c064d461..b6c72692 100644 --- a/atdb/taskdatabase/services/calculated_qualities.py +++ b/atdb/taskdatabase/services/calculated_qualities.py @@ -125,6 +125,15 @@ 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() + except Exception as error: logger.error(error) diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index dacb5917..624dbd49 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 9 Jan 2024 + <p class="footer"> Version 12 Jan 2024 </div> {% include 'taskdatabase/refresh.html' %} diff --git a/atdb/taskdatabase/tests/test_calculated_qualities.py b/atdb/taskdatabase/tests/test_calculated_qualities.py index 4aa8adf7..3563d46c 100644 --- a/atdb/taskdatabase/tests/test_calculated_qualities.py +++ b/atdb/taskdatabase/tests/test_calculated_qualities.py @@ -70,11 +70,12 @@ class TestCalculatedQualities(TestCase): # only 4 of the 7 tasks should now have calculated_qualities count = 0 - for task in Task.objects.all(): + tasks = Task.objects.all() + for task in tasks: if task.calculated_qualities['per_sasid']: count += 1 - self.assertEqual(count,5) + self.assertEqual(count,6) def test_calculated_qualities(self): -- GitLab