From f5e27c43439a1c710bda8ed70a55733ca136b537 Mon Sep 17 00:00:00 2001
From: Vermaas <vermaas@astron.nl>
Date: Tue, 23 Apr 2024 10:15:16 +0200
Subject: [PATCH] small hotfix

---
 atdb/taskdatabase/services/activities_handler.py    |  4 +++-
 atdb/taskdatabase/services/algorithms.py            | 10 +++++++++-
 atdb/taskdatabase/templates/taskdatabase/index.html |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/atdb/taskdatabase/services/activities_handler.py b/atdb/taskdatabase/services/activities_handler.py
index a5f20e10..91b669c9 100644
--- a/atdb/taskdatabase/services/activities_handler.py
+++ b/atdb/taskdatabase/services/activities_handler.py
@@ -150,8 +150,10 @@ def update_activity(task):
         # only save when changed
         if activity.is_processed != current_is_processed:
             # if the whole activity has become processed, then set the status of this activity to 'AGGREGATE'
+            # unless it was already aggregated
             if (activity.is_processed & non_discarded_found):
-                activity.status = State.AGGREGATE.value
+                if not (activity.is_aggregated):
+                    activity.status = State.AGGREGATE.value
 
             activity.save()
 
diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py
index fda6b71f..744af6a9 100644
--- a/atdb/taskdatabase/services/algorithms.py
+++ b/atdb/taskdatabase/services/algorithms.py
@@ -708,6 +708,8 @@ def add_plots(task, results, expand_image="False"):
     count = 0
 
     for plot in plots:
+
+
         # check where the plot lives and provide the translation
         try:
             # is the plot already moved to its final location on disk in the lta?
@@ -716,10 +718,16 @@ def add_plots(task, results, expand_image="False"):
             token = token_archive_disk
         except:
             # assume the orignal location.
-            base_surl = plot['surl']
+            try:
+                base_surl = plot['surl']
+            except:
+                # this means that the plot names will still show up, but the url won't work
+                base_url = 'unknown'
+
             translation = srm_to_url.split("::")
             token = token_original
 
+
         basename = plot['basename']
         checksum = plot['checksum']
         # plot_file = basename + str(plot['size'])
diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html
index c74ce8b4..5b80acf5 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 22 Apr 2024
+    <p class="footer"> Version 23 Apr 2024
 </div>
 
 {% include 'taskdatabase/refresh.html' %}
-- 
GitLab