From 1004b56e59782d99fc079290ccf731d45b94d850 Mon Sep 17 00:00:00 2001 From: vermaas <vermaas@astron.nl> Date: Tue, 14 Feb 2023 12:01:30 +0100 Subject: [PATCH] bugfix: plots didn't show when 1 task missed outputs --- atdb/taskdatabase/services/algorithms.py | 39 ++++++++++--------- .../templates/taskdatabase/index.html | 2 +- atdb/taskdatabase/views.py | 1 + 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 8d1f75c0..8f05f408 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -721,24 +721,27 @@ def construct_inspectionplots(task,source='task_id'): tasks = Task.objects.filter(sas_id=sas_id) for task in tasks: - - results += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>Task ' + str(task.id) + '</b></td></tr>' - plots = task.quality_json["plots"] - - for plot in plots: - basename = plot['basename'] - checksum = plot['checksum'] - #plot_file = basename + str(plot['size']) - plot_file = checksum - - # only add unique files - if not plot_file in plot_files: - surl = plot['surl'] + "?action=show&authz=" + str(token) - - url = surl.replace(translation[0], translation[1]) - results += '<tr><td><a href="' + url + '" target="_blank">' + basename + '</a></td></tr>' - #results += '<tr><td><a href="' + url + '" target="_blank">' + basename + '</a></td><td>'+str(plot['size'])+'</td></tr>' - plot_files.append(plot_file) + try: + results += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>Task ' + str(task.id) + '</b></td></tr>' + plots = task.quality_json["plots"] + + for plot in plots: + basename = plot['basename'] + checksum = plot['checksum'] + #plot_file = basename + str(plot['size']) + plot_file = checksum + + # only add unique files + if not plot_file in plot_files: + surl = plot['surl'] + "?action=show&authz=" + str(token) + + url = surl.replace(translation[0], translation[1]) + results += '<tr><td><a href="' + url + '" target="_blank">' + basename + '</a></td></tr>' + #results += '<tr><td><a href="' + url + '" target="_blank">' + basename + '</a></td><td>'+str(plot['size'])+'</td></tr>' + plot_files.append(plot_file) + + except Exception as error: + logger.info('task ' + str(task) + ' has no plots, skipped.') return results diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 53d85761..a69a9db5 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -34,7 +34,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 9 Februari 2023 + <p class="footer"> Version 14 Februari 2023 </div> diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index 6214606b..7ad57183 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -418,6 +418,7 @@ class ShowArchivedPage(ListView): def get_queryset(self): archived_tasks = Task.objects.filter(status='archived') + #tasks = get_filtered_tasks(self.request, archived_tasks, "sas_id") tasks = get_filtered_tasks(self.request, archived_tasks) paginator = Paginator(tasks, config.TASKS_PER_PAGE) # Show 50 tasks per page -- GitLab