Skip to content

Commit 6463a5d

Browse files
authored
Merge pull request #144 from meaningfy-ws/feature/TED-407
SPARQL execution summary
2 parents 915261b + 424fb50 commit 6463a5d

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

ted_sws/notice_validator/resources/templates/sparql_query_results_report.jinja2

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
{% macro increment(dictionary, key, increment_by=1) %}
2+
{% if dictionary.update({key: dictionary[key] + increment_by}) %} {% endif %}
3+
{% endmacro %}
4+
15
<!DOCTYPE html>
26
<html lang="en">
37
<head>
@@ -45,6 +49,11 @@
4549
</tr>
4650
</thead>
4751
<tbody>
52+
{% set counter = {
53+
'true_executions': 0,
54+
'false_executions': 0,
55+
'error_executions': 0,
56+
} %}
4857
{% for result in validation_results %}
4958
<tr>
5059
<td>{{ result.query.title }}</td>
@@ -53,9 +62,44 @@
5362
<td{% if result.result == "True" %} class="success" {% else %} class="error" {% endif %}>{{ result.result }}</td>
5463
<td>{{ result.error }}</td>
5564
</tr>
65+
{% if result.result == "True" %}
66+
{{ increment(counter, 'true_executions') }}
67+
{% elif result.error %}
68+
{{ increment(counter, 'error_executions') }}
69+
{% else %}
70+
{{ increment(counter, 'false_executions') }}
71+
{% endif %}
72+
5673
{% endfor %}
5774
</tbody>
5875
</table>
76+
<h2>Results summary</h2>
77+
<table class="display">
78+
<thead class="center aligned">
79+
<tr>
80+
<th>Result type</th>
81+
<th>Number of</th>
82+
<th>Ratio</th>
83+
</tr>
84+
</thead>
85+
<tbody>
86+
<tr>
87+
<td>{{ "True" }}</td>
88+
<td>{{ counter.true_executions }}</td>
89+
<td>{{ counter.true_executions / (counter.true_executions + counter.false_executions + counter.error_executions) }}</td>
90+
</tr>
91+
<tr>
92+
<td>{{ "False" }}</td>
93+
<td>{{ counter.false_executions }}</td>
94+
<td>{{ counter.false_executions / (counter.true_executions + counter.false_executions + counter.error_executions) }}</td>
95+
</tr>
96+
<tr>
97+
<td>{{ "Error" }}</td>
98+
<td>{{ counter.error_executions }}</td>
99+
<td>{{ counter.error_executions / (counter.true_executions + counter.false_executions + counter.error_executions) }}</td>
100+
</tr>
101+
</tbody>
102+
</table>
59103
</body>
60104
</html>
61105
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

0 commit comments

Comments
 (0)