From 000a69073f8f0dd290cdb52aedf7b6a9b3fa5e67 Mon Sep 17 00:00:00 2001 From: vermaas <vermaas@astron.nl> Date: Thu, 8 Dec 2022 12:06:33 +0100 Subject: [PATCH] small bugfix --- atdb/taskdatabase/services/algorithms.py | 143 +++++++++--------- .../taskdatabase/tasks/quality_card.html | 2 +- .../taskdatabase/validation/summary.html | 2 - 3 files changed, 75 insertions(+), 72 deletions(-) diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index 406bb17a..f102a014 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -708,85 +708,90 @@ def construct_summary(task): results = "" # find the plots in the quality json structure - summary = task.quality_json["summary"] - - total_size_input = 0 - total_size_output = 0 - - for key in summary: - record = summary[key] + try: + summary = task.quality_json["summary"] + results = "<h4>Summary File (for sas_id " + task.sas_id+ ")</h4> " + #<h4><img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="30" alt="summary"> + # Summary File (sas_id {{ task.sas_id }}) </h4> + total_size_input = 0 + total_size_output = 0 + + for key in summary: + record = summary[key] + + total_size_input += record['input_size'] + total_size_output+= record['output_size'] + + line = '' + line += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>' + key + '</b></td></tr>' + + line += '<th></th><th>Name</th><th>Size</th>' + line += '<tr><td><b>Input</b></td>' + line += '<td>' + record['input_name'] + '</td>' + line += '<td>' + str(record['input_size']) + ' (' + record['input_size_str'] + ')</td>' + line += '</tr>' + line += '<tr><td><b>Output</b></td>' + line += '<td>' + record['output_name'] + '</td>' + line += '<td>' + str(record['output_size']) + ' (' + record['output_size_str'] + ')</td>' + line += '</tr>' + line += '<tr><td><b>Ratio</b></td>' + line += '<td>' + str(round(record['size_ratio'],3)) + '</td>' + line += '</tr>' - total_size_input += record['input_size'] - total_size_output+= record['output_size'] + try: + input_content = record['input_content'] + if input_content: + line += '<th>Input Content</th>' + line += '<tr><td colspan="3">' + for filename in input_content: + line += filename + '\n' + line += '</td></tr>' + except: + pass - line = '' - line += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>' + key + '</b></td></tr>' + try: + output_content = record['output_content'] + if output_content: + line += '<th>Output Content</th>' + line += '<tr><td colspan="3">' + for filename in output_content: + line += filename + '\n' + line += '</td></tr>' + except: + pass - line += '<th></th><th>Name</th><th>Size</th>' - line += '<tr><td><b>Input</b></td>' - line += '<td>' + record['input_name'] + '</td>' - line += '<td>' + str(record['input_size']) + ' (' + record['input_size_str'] + ')</td>' - line += '</tr>' - line += '<tr><td><b>Output</b></td>' - line += '<td>' + record['output_name'] + '</td>' - line += '<td>' + str(record['output_size']) + ' (' + record['output_size_str'] + ')</td>' - line += '</tr>' - line += '<tr><td><b>Ratio</b></td>' - line += '<td>' + str(round(record['size_ratio'],3)) + '</td>' - line += '</tr>' + try: + to_add = record['to_add'] + if to_add: + line += '<th>to_add</th>' + line += '<tr><td colspan="3">' + for filename in to_add: + line += filename + '\n' + line += '</td></tr>' + except: + pass - try: - input_content = record['input_content'] - if input_content: - line += '<th>Input Content</th>' - line += '<tr><td colspan="3">' - for filename in input_content: - line += filename + '\n' - line += '</td></tr>' - except: - pass + try: + to_delete = record['to_delete'] + if to_delete: + line += '<th>to_delete</th>' + line += '<tr><td colspan="3">' + for filename in to_delete: + line += filename + '\n' + line += '</td></tr>' + except: + pass - try: - output_content = record['output_content'] - if output_content: - line += '<th>Output Content</th>' - line += '<tr><td colspan="3">' - for filename in output_content: - line += filename + '\n' - line += '</td></tr>' - except: - pass + results += line try: - to_add = record['to_add'] - if to_add: - line += '<th>to_add</th>' - line += '<tr><td colspan="3">' - for filename in to_add: - line += filename + '\n' - line += '</td></tr>' - except: - pass + results += '<th>Totals</th>' + results += '<tr><td colspan="1"><b>Input size</b></td><td>' + str(total_size_input) + '</td></tr>' + results += '<tr><td colspan="1"><b>Output size</b><td>' + str(total_size_output) + '</td></tr>' + results += '<tr><td colspan="1"><b>Ratio</b></td><td>' + str(total_size_output/total_size_output) + '</td></tr>' - try: - to_delete = record['to_delete'] - if to_delete: - line += '<th>to_delete</th>' - line += '<tr><td colspan="3">' - for filename in to_delete: - line += filename + '\n' - line += '</td></tr>' except: pass - - results += line - - try: - results += '<th>Totals</th>' - results += '<tr><td colspan="1"><b>Input size</b></td><td>' + str(total_size_input) + '</td></tr>' - results += '<tr><td colspan="1"><b>Output size</b><td>' + str(total_size_output) + '</td></tr>' - results += '<tr><td colspan="1"><b>Ratio</b></td><td>' + str(total_size_output/total_size_output) + '</td></tr>' - except: pass diff --git a/atdb/taskdatabase/templates/taskdatabase/tasks/quality_card.html b/atdb/taskdatabase/templates/taskdatabase/tasks/quality_card.html index 853f162e..3f3e7c32 100644 --- a/atdb/taskdatabase/templates/taskdatabase/tasks/quality_card.html +++ b/atdb/taskdatabase/templates/taskdatabase/tasks/quality_card.html @@ -4,7 +4,7 @@ <table class="table table-striped"> {{ quality | safe }} </table> - <h4>Summary File</h4> + <table class="table table-striped"> {{ summary | safe }} </table> diff --git a/atdb/taskdatabase/templates/taskdatabase/validation/summary.html b/atdb/taskdatabase/templates/taskdatabase/validation/summary.html index 83f69f62..23989b6f 100644 --- a/atdb/taskdatabase/templates/taskdatabase/validation/summary.html +++ b/atdb/taskdatabase/templates/taskdatabase/validation/summary.html @@ -5,8 +5,6 @@ <div class="card"> <div class="card-body"> - <h4><img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="30" alt="summary"> - Summary File (sas_id {{ task.sas_id }}) </h4> <table class="table table-striped"> {{ my_summary | safe }} </table> -- GitLab