Skip to content

Commit 86ececf

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

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

api/confluence/api_confluence.py

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,76 @@ 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 panel macro.
658+
Uses the exact format Confluence uses in storage.
659+
"""
660+
panels = {
661+
# Green panel with shield icon (Approved)
662+
"approved": (
663+
'<ac:structured-macro ac:name="panel" ac:schema-version="1">'
664+
'<ac:parameter ac:name="panelIcon">:security-shield:</ac:parameter>'
665+
'<ac:parameter ac:name="panelIconId">a13e390c-702a-43df-925b-7bdc5de46527</ac:parameter>'
666+
'<ac:parameter ac:name="panelIconText">:security-shield:</ac:parameter>'
667+
'<ac:parameter ac:name="bgColor">#E3FCEF</ac:parameter>'
668+
'<ac:rich-text-body>'
669+
'<p>Approved</p>'
670+
'</ac:rich-text-body>'
671+
'</ac:structured-macro>'
672+
),
673+
674+
# Blue panel with circular arrows (Pending)
675+
"pending": (
676+
'<ac:structured-macro ac:name="panel" ac:schema-version="1">'
677+
'<ac:parameter ac:name="panelIcon">:arrows_counterclockwise:</ac:parameter>'
678+
'<ac:parameter ac:name="panelIconId">1f504</ac:parameter>'
679+
'<ac:parameter ac:name="panelIconText">:arrows_counterclockwise:</ac:parameter>'
680+
'<ac:parameter ac:name="bgColor">#DEEBFF</ac:parameter>'
681+
'<ac:rich-text-body>'
682+
'<p>Pending</p>'
683+
'</ac:rich-text-body>'
684+
'</ac:structured-macro>'
685+
),
686+
687+
# Yellow panel with info icon (Informational)
688+
"informational": (
689+
'<ac:structured-macro ac:name="panel" ac:schema-version="1">'
690+
'<ac:parameter ac:name="panelIcon">:information_source:</ac:parameter>'
691+
'<ac:parameter ac:name="panelIconId">2139</ac:parameter>'
692+
'<ac:parameter ac:name="panelIconText">:information_source:</ac:parameter>'
693+
'<ac:parameter ac:name="bgColor">#FFFAE6</ac:parameter>'
694+
'<ac:rich-text-body>'
695+
'<p>Info</p>'
696+
'</ac:rich-text-body>'
697+
'</ac:structured-macro>'
698+
),
699+
700+
# Gray panel with question mark (Not Reviewed)
701+
"not-reviewed": (
702+
'<ac:structured-macro ac:name="panel" ac:schema-version="1">'
703+
'<ac:parameter ac:name="panelIcon">:grey_question:</ac:parameter>'
704+
'<ac:parameter ac:name="panelIconId">2754</ac:parameter>'
705+
'<ac:parameter ac:name="panelIconText">:grey_question:</ac:parameter>'
706+
'<ac:parameter ac:name="bgColor">#F4F5F7</ac:parameter>'
707+
'<ac:rich-text-body>'
708+
'<p>Review</p>'
709+
'</ac:rich-text-body>'
710+
'</ac:structured-macro>'
711+
),
712+
}
713+
714+
if not status:
715+
return panels["not-reviewed"]
716+
717+
return panels.get(status.lower().strip(), panels["not-reviewed"])
718+
719+
655720
def table_row_write(report_title, report_description,
656-
attachment_filename, looker_graph_url):
721+
attachment_filename, looker_graph_url, approval_status):
722+
723+
status_icon = get_metric_status_icon(approval_status)
724+
657725
return (
658726
f"""
659727
<row>
@@ -663,6 +731,7 @@ def table_row_write(report_title, report_description,
663731
<a href="{looker_graph_url}"><ac:image>
664732
<ri:attachment ri:filename="{attachment_filename}"/>
665733
</ac:image></a></td>
734+
<td style="text-align: center;">{status_icon}</td>
666735
</row>
667736
"""
668737
)
@@ -680,7 +749,8 @@ def page_html(page_id, sections):
680749
row = table_row_write(report["report-title"],
681750
report["report-description"],
682751
report["attachment-filename"],
683-
report["looker-graph-url"])
752+
report["looker-graph-url"],
753+
report.get("approval-status", "not-reviewed"))
684754
rows += row
685755

686756
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)