Skip to content

Commit 9da2a59

Browse files
Merge pull request #48 from digital-land/overview_report_modificxation
Update Issue Summary Table
2 parents 34102b1 + cf0c942 commit 9da2a59

File tree

4 files changed

+118
-50
lines changed

4 files changed

+118
-50
lines changed

application/blueprints/report/views.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
get_grouped_entity_count,
3737
)
3838
from application.data_access.overview.issue_summary import (
39-
get_issue_summary,
40-
get_issue_summary_for_csv,
39+
get_full_issue_summary,
40+
get_full_issue_summary_for_csv,
4141
)
4242
from application.data_access.overview.source_and_resource_queries import (
4343
get_datasets_summary,
@@ -96,7 +96,7 @@ def overview():
9696
"internal_errors_timeseries": internal_errors_timeseries,
9797
}
9898

99-
issue_summary = get_issue_summary()
99+
issue_summary = get_full_issue_summary()
100100

101101
return render_template(
102102
"reporting/overview.html",
@@ -162,8 +162,8 @@ def download_csv():
162162
)
163163
file_path = generate_odp_summary_csv(conformance_df)
164164
return send_file(file_path, download_name="odp-conformance.csv")
165-
if type == "issue-summary":
166-
overview_issue_summary = get_issue_summary_for_csv()
165+
if type == "endpoint_dataset_issue_type_summary":
166+
overview_issue_summary = get_full_issue_summary_for_csv()
167167
file_path = generate_overview_issue_summary_csv(overview_issue_summary)
168168
return send_file(file_path, download_name="overview_issue_summary.csv")
169169

application/data_access/overview/issue_summary.py

+89-39
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
from application.data_access.datasette_utils import get_datasette_query_issue_summary
1+
import pandas as pd
22

3+
from application.data_access.datasette_utils import get_datasette_query
34

4-
def get_issue_summary():
5-
issues_df = get_datasette_query_issue_summary(
6-
"performance/endpoint_dataset_issue_type_summary"
7-
)
5+
6+
def get_full_issue_summary():
7+
pagination_incomplete = True
8+
offset = 0
9+
issue_summary_df_list = []
10+
while pagination_incomplete:
11+
issue_summary_df = get_issue_summary(offset)
12+
issue_summary_df_list.append(issue_summary_df)
13+
pagination_incomplete = len(issue_summary_df) == 1000
14+
offset += 1000
15+
issues_df = pd.concat(issue_summary_df_list)
816

917
# Convert DataFrame to a list of dictionaries (rows)
1018
rows = issues_df.to_dict(orient="records")
@@ -14,46 +22,56 @@ def get_issue_summary():
1422
{
1523
"display_severity": "No issues",
1624
"severity": "",
17-
"total_count_percentage": 0.0,
25+
"total_count": 0,
26+
"total_count_percentage": 0.00,
1827
"internal_count": 0,
28+
"internal_count_percentage": 0.00,
1929
"external_count": 0,
20-
"total_count": 0,
30+
"external_count_percentage": 0.00,
2131
"classes": "reporting-good-background",
2232
},
2333
{
2434
"display_severity": "Info",
2535
"severity": "info",
26-
"total_count_percentage": 0.0,
36+
"total_count": 0,
37+
"total_count_percentage": 0.00,
2738
"internal_count": 0,
39+
"internal_count_percentage": 0.00,
2840
"external_count": 0,
29-
"total_count": 0,
41+
"external_count_percentage": 0.00,
3042
"classes": "reporting-good-background",
3143
},
3244
{
3345
"display_severity": "Warning",
3446
"severity": "warning",
35-
"total_count_percentage": 0.0,
47+
"total_count": 0,
48+
"total_count_percentage": 0.00,
3649
"internal_count": 0,
50+
"internal_count_percentage": 0.00,
3751
"external_count": 0,
38-
"total_count": 0,
52+
"external_count_percentage": 0.00,
3953
"classes": "reporting-medium-background",
4054
},
4155
{
4256
"display_severity": "Error",
4357
"severity": "error",
44-
"total_count_percentage": 0.0,
58+
"total_count": 0,
59+
"total_count_percentage": 0.00,
4560
"internal_count": 0,
61+
"internal_count_percentage": 0.00,
4662
"external_count": 0,
47-
"total_count": 0,
63+
"external_count_percentage": 0.00,
4864
"classes": "reporting-bad-background",
4965
},
5066
{
5167
"display_severity": "Notice",
5268
"severity": "notice",
53-
"total_count_percentage": 0.0,
69+
"total_count": 0,
70+
"total_count_percentage": 0.00,
5471
"internal_count": 0,
72+
"internal_count_percentage": 0.00,
5573
"external_count": 0,
56-
"total_count": 0,
74+
"external_count_percentage": 0.00,
5775
"classes": "reporting-bad-background",
5876
},
5977
]
@@ -93,53 +111,64 @@ def get_issue_summary():
93111
# Add issue_severity row
94112
stats_rows = []
95113
for issue_severity in issue_severity_counts:
114+
if issue_severity["internal_count"] > 0:
115+
issue_severity["internal_count_percentage"] = round(
116+
(issue_severity["internal_count"] / total_issues) * 100, 2
117+
)
118+
119+
if issue_severity["external_count"] > 0:
120+
issue_severity["external_count_percentage"] = round(
121+
(issue_severity["external_count"] / total_issues) * 100, 2
122+
)
123+
96124
if issue_severity["total_count"] > 0:
97-
issue_severity[
98-
"total_count_percentage"
99-
] = f"{int((issue_severity['total_count'] / total_issues) * 100)}%"
125+
issue_severity["total_count_percentage"] = round(
126+
(issue_severity["total_count"] / total_issues) * 100, 2
127+
)
128+
100129
stats_rows.append(
101130
[
102131
{
103132
"text": issue_severity["display_severity"],
104133
"classes": issue_severity["classes"] + " reporting-table-cell",
105134
},
106135
{
107-
"text": issue_severity["total_count"],
108-
"classes": "reporting-table-cell",
109-
},
110-
{
111-
"text": issue_severity["total_count_percentage"],
136+
"text": f"{issue_severity['internal_count']} ({issue_severity['internal_count_percentage']}%)",
112137
"classes": "reporting-table-cell",
113138
},
114139
{
115-
"text": issue_severity["internal_count"],
140+
"text": f"{issue_severity['external_count']} ({issue_severity['external_count_percentage']}%)",
116141
"classes": "reporting-table-cell",
117142
},
118143
{
119-
"text": issue_severity["external_count"],
144+
"text": f"{issue_severity['total_count']} ({issue_severity['total_count_percentage']}%)",
120145
"classes": "reporting-table-cell",
121146
},
122147
]
123148
)
124149

125-
# Add totals row
150+
# Add totals row, the bottom
126151
stats_rows.append(
127152
[
128153
{"text": "Total", "classes": "reporting-table-cell"},
154+
{
155+
"text": f"{total_internal} ({round((total_internal/total_issues)*100, 2)}%)",
156+
"classes": "reporting-table-cell",
157+
},
158+
{
159+
"text": f"{total_external} ({round((total_external/total_issues)*100, 2)}%)",
160+
"classes": "reporting-table-cell",
161+
},
129162
{"text": total_issues, "classes": "reporting-table-cell"},
130-
{"text": "", "classes": "reporting-table-cell"},
131-
{"text": total_internal, "classes": "reporting-table-cell"},
132-
{"text": total_external, "classes": "reporting-table-cell"},
133163
]
134164
)
135165

136166
# Define headers
137167
stats_headers = [
138-
{"text": "Issue Severity"},
139-
{"text": "Count"},
140-
{"text": "% Count"},
141-
{"text": "Internal"},
142-
{"text": "External"},
168+
{"text": "Severity"},
169+
{"text": "Internal (%)"},
170+
{"text": "External (%)"},
171+
{"text": "Total (%)"},
143172
]
144173

145174
return {
@@ -153,16 +182,23 @@ def get_issue_summary():
153182
}
154183

155184

156-
def get_issue_summary_for_csv():
157-
issue_summary_df = get_datasette_query_issue_summary(
158-
"performance/endpoint_dataset_issue_type_summary"
159-
)
185+
def get_full_issue_summary_for_csv():
186+
pagination_incomplete = True
187+
offset = 0
188+
issue_summary_df_list = []
189+
while pagination_incomplete:
190+
issue_summary_df = get_issue_summary_for_csv(offset)
191+
issue_summary_df_list.append(issue_summary_df)
192+
pagination_incomplete = len(issue_summary_df) == 1000
193+
offset += 1000
194+
issue_summary_df = pd.concat(issue_summary_df_list)
195+
160196
issue_summary_df = issue_summary_df[issue_summary_df["count_issues"].notna()]
161197

162198
return issue_summary_df[
163199
[
164200
"organisation",
165-
"name",
201+
"organisation_name",
166202
"pipeline",
167203
"issue_type",
168204
"severity",
@@ -181,3 +217,17 @@ def get_issue_summary_for_csv():
181217
"resource_end_date",
182218
]
183219
]
220+
221+
222+
def get_issue_summary(offset):
223+
sql = f"""
224+
select count_issues, severity, responsibility from endpoint_dataset_issue_type_summary limit 1000 offset {offset}
225+
"""
226+
return get_datasette_query("performance", sql)
227+
228+
229+
def get_issue_summary_for_csv(offset):
230+
sql = f"""
231+
select * from endpoint_dataset_issue_type_summary limit 1000 offset {offset}
232+
"""
233+
return get_datasette_query("performance", sql)

application/templates/reporting/overview.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ <h2>Endpoint Collection Stats</h2>
3636
<p id="errors" class="reporting-clear-boths govuk-body">Endpoint errors: </p>
3737
</div>
3838
<div class="govuk-!-margin-top-6 govuk-!-width-full govuk-!-text-align-centre">
39-
<a class="govuk-link" href="{{ url_for('reporting.download_csv')}}?type=issue-summary" id="download-button">
39+
<a class="govuk-link" href="{{ url_for('reporting.download_csv')}}?type=endpoint_dataset_issue_type_summary" id="download-button">
4040
Download Issues Summary Table
4141
</a>
4242
</div>
4343

4444
</div>
4545
<div class="govuk-grid-column-one-half govuk-!-padding-left-9">
46-
<h1 class="govuk-heading-xl">Issues summary:</h1>
46+
<h1 class="govuk-heading-xl">Issues:</h1>
4747
{{ govukTable({
4848
"head": issue_summary.stats_headers,
4949
"rows": issue_summary.stats_rows,
50-
"classes": "reporting-table"
50+
"classes": "reporting-table app-table-issue-summary"
5151
}) }}
5252
<p class="govuk-!-text-align-centre govuk-body govuk-!-width-full"><strong class="govuk-!-font-size-36">{{issue_summary.endpoints_no_issues.count}}</strong> / {{issue_summary.endpoints_no_issues.total_endpoints}} endpoints with no issues</p>
5353
</div>

src/scss/application.scss

+21-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
.app-summary-list__value--warning {
4545
padding-left: 10px;
4646
background: govuk-tint(govuk-colour("yellow"), 75);
47-
border-left: 4px solid govuk-colour('yellow');
47+
border-left: 4px solid govuk-colour("yellow");
4848

4949
.app-summary-list__value__annotation {
5050
color: govuk-shade(govuk-colour("yellow"), 65);
@@ -64,7 +64,7 @@
6464
.app-summary-list__value--error {
6565
padding-left: 10px;
6666
background: govuk-tint(govuk-colour("red"), 80);
67-
border-left: 4px solid govuk-colour('red');
67+
border-left: 4px solid govuk-colour("red");
6868

6969
.app-summary-list__value__annotation {
7070
color: govuk-shade(govuk-colour("red"), 30);
@@ -80,7 +80,7 @@
8080
padding: 10px;
8181
color: govuk-shade(govuk-colour("red"), 30);
8282
background: govuk-tint(govuk-colour("red"), 80);
83-
border-left: 4px solid govuk-colour('red');
83+
border-left: 4px solid govuk-colour("red");
8484
}
8585

8686
.js-hidden {
@@ -105,3 +105,21 @@
105105
.app-main-wrapper {
106106
@include moj-width-container;
107107
}
108+
109+
.app-table-issue-summary .govuk-table__header {
110+
padding-top: 0;
111+
}
112+
113+
.app-table-issue-summary .govuk-table__body {
114+
white-space: normal;
115+
116+
@media (min-width: 71.0625em) {
117+
white-space: nowrap;
118+
}
119+
120+
.govuk-table__row:last-child {
121+
.govuk-table__cell.reporting-table-cell {
122+
font-weight: 700;
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)