Skip to content

Commit 8196236

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

File tree

2 files changed

+88
-2
lines changed

2 files changed

+88
-2
lines changed

api/confluence/api_confluence.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,78 @@ 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 custom panel with emoji.
658+
Uses the span + data-emoji-short-name format that Confluence actually uses.
659+
"""
660+
panels = {
661+
# Green panel with shield emoji
662+
"approved": (
663+
'<ac:structured-macro ac:name="panel">'
664+
'<ac:parameter ac:name="bgColor">#E3FCEF</ac:parameter>'
665+
'<ac:parameter ac:name="borderColor">#00875A</ac:parameter>'
666+
'<ac:rich-text-body>'
667+
'<p>'
668+
'<span data-emoji-short-name=":security-shield:"></span>'
669+
'</p>'
670+
'</ac:rich-text-body>'
671+
'</ac:structured-macro>'
672+
),
673+
674+
# Blue panel with circular arrows
675+
"pending": (
676+
'<ac:structured-macro ac:name="panel">'
677+
'<ac:parameter ac:name="bgColor">#DEEBFF</ac:parameter>'
678+
'<ac:parameter ac:name="borderColor">#0747A6</ac:parameter>'
679+
'<ac:rich-text-body>'
680+
'<p>'
681+
'<span data-emoji-short-name=":arrows_counterclockwise:">'
682+
'</span>'
683+
'</p>'
684+
'</ac:rich-text-body>'
685+
'</ac:structured-macro>'
686+
),
687+
688+
# Yellow panel with info icon
689+
"informational": (
690+
'<ac:structured-macro ac:name="panel">'
691+
'<ac:parameter ac:name="bgColor">#FFFAE6</ac:parameter>'
692+
'<ac:parameter ac:name="borderColor">#FF991F</ac:parameter>'
693+
'<ac:rich-text-body>'
694+
'<p>'
695+
'<span data-emoji-short-name=":information_source:">'
696+
'</span>'
697+
'</p>'
698+
'</ac:rich-text-body>'
699+
'</ac:structured-macro>'
700+
),
701+
702+
# Gray panel with question mark
703+
"not-reviewed": (
704+
'<ac:structured-macro ac:name="panel">'
705+
'<ac:parameter ac:name="bgColor">#F4F5F7</ac:parameter>'
706+
'<ac:parameter ac:name="borderColor">#A5ADBA</ac:parameter>'
707+
'<ac:rich-text-body>'
708+
'<p>'
709+
'<span data-emoji-short-name=":grey_question:"></span>'
710+
'</p>'
711+
'</ac:rich-text-body>'
712+
'</ac:structured-macro>'
713+
),
714+
}
715+
716+
if not status:
717+
return panels["not-reviewed"]
718+
719+
return panels.get(status.lower().strip(), panels["not-reviewed"])
720+
721+
655722
def table_row_write(report_title, report_description,
656-
attachment_filename, looker_graph_url):
723+
attachment_filename, looker_graph_url, approval_status):
724+
725+
status_icon = get_metric_status_icon(approval_status)
726+
657727
return (
658728
f"""
659729
<row>
@@ -663,6 +733,7 @@ def table_row_write(report_title, report_description,
663733
<a href="{looker_graph_url}"><ac:image>
664734
<ri:attachment ri:filename="{attachment_filename}"/>
665735
</ac:image></a></td>
736+
<td style="text-align: center;">{status_icon}</td>
666737
</row>
667738
"""
668739
)
@@ -680,7 +751,8 @@ def page_html(page_id, sections):
680751
row = table_row_write(report["report-title"],
681752
report["report-description"],
682753
report["attachment-filename"],
683-
report["looker-graph-url"])
754+
report["looker-graph-url"],
755+
report.get("approval-status", "not-reviewed"))
684756
rows += row
685757

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