From b1177b6c44ccd3d7c355e360c6042f9544316682 Mon Sep 17 00:00:00 2001
From: Vermaas <vermaas@astron.nl>
Date: Thu, 27 Jul 2023 11:36:45 +0200
Subject: [PATCH] small fix to ignore missing QA fields

---
 atdb/taskdatabase/models.py              | 14 ++++++++++----
 atdb/taskdatabase/services/algorithms.py | 10 +++++++---
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py
index 108cdb5d..c5e7c139 100644
--- a/atdb/taskdatabase/models.py
+++ b/atdb/taskdatabase/models.py
@@ -52,12 +52,18 @@ def convert_quality_to_list_for_template(task):
 
     try:
         list.append(str(task.quality_json['uv-coverage']))
+    except:
+        list.append("-")
+
+    try:
         list.append(str(task.quality_json['sensitivity']))
-        list.append(str(task.quality_json['observing-conditions']))
-        #list.append("-")
+    except:
+        list.append("-")
 
-    except Exception as err:
-        pass
+    try:
+        list.append(str(task.quality_json['observing-conditions']))
+    except:
+        list.append("-")
 
     return list
 
diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py
index f93a5e05..f9a331d1 100644
--- a/atdb/taskdatabase/services/algorithms.py
+++ b/atdb/taskdatabase/services/algorithms.py
@@ -120,9 +120,13 @@ def convert_quality_to_html(task):
         results += "<tr><td><b>Project</b></td><td>" + str(task.project) + "</td></tr>"
         results += "<tr><td><b>ATDB Filter</b></td><td>" + str(task.filter) + "</td></tr>"
         results += "<tr><td><b>Quality</b></td><td>" + str(task.quality) + "</td></tr>"
-        results += "<tr><td><b>QA uv-coverage</b></td><td>" + str(task.quality_json['uv-coverage']) + "</td></tr>"
-        results += "<tr><td><b>QA sensitivity</b></td><td>" + str(task.quality_json['sensitivity']) + "</td></tr>"
-        results += "<tr><td><b>QA observing-conditions</b></td><td>" + str(task.quality_json['observing-conditions']) + "</td></tr>"
+        try:
+            results += "<tr><td><b>QA uv-coverage</b></td><td>" + str(task.quality_json['uv-coverage']) + "</td></tr>"
+            results += "<tr><td><b>QA sensitivity</b></td><td>" + str(task.quality_json['sensitivity']) + "</td></tr>"
+            results += "<tr><td><b>QA observing-conditions</b></td><td>" + str(task.quality_json['observing-conditions']) + "</td></tr>"
+        except:
+            # not all tasks have this QA information, if missing, continue (the show must go on)
+            pass
 
         try:
             results += "<tr><td><b>high_flagging</b></td><td>" + str(task.quality_json['details']['high_flagging']) + "</td></tr>"
-- 
GitLab