Skip to content

Commit 399bd8e

Browse files
committed
Feat: Add new column for metric approval to generated Looker Report Confluence tables
For #238
1 parent b8db303 commit 399bd8e

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

api/confluence/api_confluence.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,51 @@ def image_attachments_upload(page_id):
652652
# ------------------------------------------------------------------
653653

654654

655+
def get_metric_status_icon(status: str) -> str:
656+
"""
657+
Convert metric status to Confluence native status lozenge.
658+
These are guaranteed to work in Confluence.
659+
"""
660+
macros = {
661+
"approved": (
662+
'<ac:structured-macro ac:name="status" ac:schema-version="1">'
663+
'<ac:parameter ac:name="colour">Green</ac:parameter>'
664+
'<ac:parameter ac:name="title">:security_shield: APPROVED</ac:parameter>'
665+
'</ac:structured-macro>'
666+
),
667+
668+
"pending": (
669+
'<ac:structured-macro ac:name="status" ac:schema-version="1">'
670+
'<ac:parameter ac:name="colour">Blue</ac:parameter>'
671+
'<ac:parameter ac:name="title">:arrows_counterclockwise: PENDING</ac:parameter>'
672+
'</ac:structured-macro>'
673+
),
674+
675+
"informational": (
676+
'<ac:structured-macro ac:name="status" ac:schema-version="1">'
677+
'<ac:parameter ac:name="colour">Yellow</ac:parameter>'
678+
'<ac:parameter ac:name="title">:information_source: INFO</ac:parameter>'
679+
'</ac:structured-macro>'
680+
),
681+
"not-reviewed": (
682+
'<ac:structured-macro ac:name="status" ac:schema-version="1">'
683+
'<ac:parameter ac:name="colour">Grey</ac:parameter>'
684+
'<ac:parameter ac:name="title">? REVIEW</ac:parameter>'
685+
'</ac:structured-macro>'
686+
),
687+
}
688+
689+
if not status:
690+
return macros["pending"]
691+
692+
return macros.get(status.lower().strip(), macros["pending"])
693+
694+
655695
def table_row_write(report_title, report_description,
656-
attachment_filename, looker_graph_url):
696+
attachment_filename, looker_graph_url, approval_status):
697+
698+
status_icon = get_metric_status_icon(approval_status)
699+
657700
return (
658701
f"""
659702
<row>
@@ -663,6 +706,7 @@ def table_row_write(report_title, report_description,
663706
<a href="{looker_graph_url}"><ac:image>
664707
<ri:attachment ri:filename="{attachment_filename}"/>
665708
</ac:image></a></td>
709+
<td style="text-align: center;">{status_icon}</td>
666710
</row>
667711
"""
668712
)
@@ -680,7 +724,8 @@ def page_html(page_id, sections):
680724
row = table_row_write(report["report-title"],
681725
report["report-description"],
682726
report["attachment-filename"],
683-
report["looker-graph-url"])
727+
report["looker-graph-url"],
728+
report.get("approval-status", "not-reviewed"))
684729
rows += row
685730

686731
html_content += f"""

config/confluence/yaml/data-insights-test-data-insights.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,72 @@ wiki_page:
88
report-description: "A holistic, categorical score to summarize test health at a glance."
99
attachment-filename: "fenix-ui-test-health-index.png"
1010
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2901"
11+
approval-status: "approved"
1112
- report-title: "Focus UI Test Health Index"
1213
report-description: "A holistic, categorical score to summarize test health at a glance."
1314
attachment-filename: "focus-ui-test-health-index.png"
1415
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2902"
16+
approval-status: "approved"
1517
- report-title: "Fenix UI Test Flaky Rate KPI (Current Month Average)"
1618
report-description: "The average percentage of flaky tests in the last 30 days."
1719
attachment-filename: "fenix-ui-test-flaky-rate-kpi-cur-month-avg.png"
1820
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2898"
21+
approval-status: "approved"
1922
- report-title: "Focus UI Test Flaky Rate KPI (Current Month Average)"
2023
report-description: "The average percentage of flaky tests in the last 30 days."
2124
attachment-filename: "focus-ui-test-flaky-rate-kpi-cur-month-avg.png"
2225
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2900"
26+
approval-status: "approved"
2327
- report-title: "Fenix UI Test Failure Rate KPI (Current Month Average)"
2428
report-description: "The average percentage of failed tests in the last 30 days."
2529
attachment-filename: "fenix-ui-test-failure-rate-kpi-cur-month-avg.png"
2630
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2903"
31+
approval-status: "approved"
2732
- report-title: "Focus UI Test Failure Rate KPI (Current Month Average)"
2833
report-description: "The average percentage of failed tests in the last 30 days."
2934
attachment-filename: "focus-ui-test-failure-rate-kpi-cur-month-avg.png"
3035
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2906"
36+
approval-status: "approved"
3137
- report-title: "Fenix UI Test Flaky Rate KPI (Month over Month)"
3238
report-description: "The percentage of flaky tests in the last 30 days compared to the previous 30 days."
3339
attachment-filename: "fenix-ui-test-flaky-rate-month-over-month-kpi.png"
3440
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2835"
41+
approval-status: "approved"
3542
- report-title: "Focus UI Test Flaky Rate KPI (Month over Month)"
3643
report-description: "The percentage of flaky tests in the last 30 days compared to the previous 30 days."
3744
attachment-filename: "focus-ui-test-flaky-rate-month-over-month-kpi.png"
3845
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2839"
46+
approval-status: "approved"
3947
- report-title: "Fenix UI Test Failure Rate KPI (Month over Month)"
4048
report-description: "The percentage of failed tests in the last 30 days compared to the previous 30 days."
4149
attachment-filename: "fenix-ui-test-failure-rate-month-over-month-kpi.png"
4250
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2837"
51+
approval-status: "approved"
4352
- report-title: "Focus UI Test Failure Rate KPI (Month over Month)"
4453
report-description: "The percentage of failed tests in the last 30 days compared to the previous 30 days."
4554
attachment-filename: "focus-ui-test-failure-rate-month-over-month-kpi.png"
4655
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2907"
56+
approval-status: "approved"
4757
- report-title: "Fenix UI Test Flaky Rate by Month"
4858
report-description: "The percentage of flaky tests by month."
4959
attachment-filename: "fenix-ui-test-flaky-rate-by-month.png"
5060
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2869"
61+
approval-status: "approved"
5162
- report-title: "Fenix UI Test Failure Rate by Month"
5263
report-description: "The percentage of failed tests by month."
5364
attachment-filename: "fenix-ui-test-failure-rate-by-month.png"
5465
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2871"
66+
approval-status: "approved"
5567
- report-title: "Fenix UI Test Monthly Run Volume of UI Tests"
5668
report-description: "The number of tests run by month across all jobs."
5769
attachment-filename: "fenix-ui-test-monthly-run-volume.png"
5870
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2891"
71+
approval-status: "approved"
5972
- report-title: "Focus UI Test Monthly Run Volume of UI Tests"
6073
report-description: "The number of tests run by month across all jobs."
6174
attachment-filename: "focus-ui-test-monthly-run-volume.png"
6275
looker-graph-url: "https://mozilla.cloud.looker.com/looks/2893"
76+
approval-status: "approved"
6377

6478
- name: "UI Test Data Insights - iOS"
6579
reports:

0 commit comments

Comments
 (0)