Skip to content

Commit 381f98a

Browse files
committed
refactor: right align build regressions in metrics email
Closes #1938 Signed-off-by: Marcelo Robert Santos <4mrSantos@gmail.com>
1 parent da43117 commit 381f98a

2 files changed

Lines changed: 35 additions & 28 deletions

File tree

backend/kernelCI_app/management/commands/templates/metrics_report.txt.j2

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,37 @@ Period: {{ start_datetime }} to {{ end_datetime }}
5454

5555
{% if build_incidents_by_origin -%}
5656

57-
{{ "{:<12}".format(" Origin") -}}
58-
{{ "{:<18}".format("Regressions") -}}
59-
{{ "{:<19}".format("Affected") -}}
60-
Affected builds by top issues
61-
{{ "{:<12}".format("") -}}
62-
{{ "{:<18}".format("(known + new)") -}}
63-
{{ "{:<19}".format("Builds (total)") -}}
64-
{{ "{:<8}".format("#1") -}}{{ "{:<8}".format("#2") -}}#3
65-
─────────────────────────────────────────────────────────────────────────
57+
{% set origin_space = 12 -%}
58+
{% set known_reg_space = 6 -%}
59+
{% set new_reg_space = 6 -%}
60+
{% set total_reg_space = 6 -%}
61+
{% set reg_space = known_reg_space + new_reg_space + total_reg_space -%}
62+
{% set affected_space = 16 -%}
63+
{% set ind_issues_space = 10 -%}
64+
{{ "{:<{width}}".format(" Origin", width=origin_space) -}}
65+
{{ "{:>{width}}".format("Regressions", width=reg_space) -}}
66+
{{ "{:>{width}}".format("Affected", width=affected_space) -}}
67+
{{ "{:>{width}}".format("Affected builds by top issues", width=ind_issues_space*3 + 1) }} {#- +1 to get to a 2-space gap, same for the #1 issue and the space after total incidents #}
68+
{{ "{:<{width}}".format("", width=origin_space) -}}
69+
{{ "{:>{width}}".format("(known + new)", width=reg_space) -}}
70+
{{ "{:>{width}}".format("Builds (total)", width=affected_space) -}}
71+
{{ "{:>{width}}".format("#1", width=ind_issues_space + 1) -}}{{ "{:>{width}}".format("#2", width=ind_issues_space) -}}{{ "{:>{width}}".format("#3", width=ind_issues_space) }}
72+
───────────────────────────────────────────────────────────────────────────
6673
{% for origin, data in build_incidents_by_origin.items() | sort -%}
67-
{{ "{:<12}".format(" " + origin) -}}
68-
{{ "{:<4}".format(fmt(data['n_existing_issues'])) -}} +{{" "}}
69-
{{- "{:<4}".format(fmt(data['n_new_issues'])) -}} ={{" "}}
70-
{{- "{:<6}".format(fmt(data['n_total_issues'])) -}}
71-
{{ "{:<19}".format(fmt(data['total_incidents'])) -}}
74+
{{ "{:<{width}}".format(" " + origin, width=origin_space) -}}
75+
{{ "{:>{width}}".format(fmt(data['n_existing_issues']) + " +", width=known_reg_space) }}
76+
{{- "{:>{width}}".format(fmt(data['n_new_issues']) + " =", width=new_reg_space) }}
77+
{{- "{:>{width}}".format(fmt(data['n_total_issues']), width=total_reg_space) -}}
78+
{{ "{:>{width}}".format(fmt(data['total_incidents']), width=affected_space) -}} {{ " " -}}
7279
{% for issue_key, data in top_issues_by_origin.get(origin, {}).items() -%}
73-
{{ "{:<8}".format(fmt(data['total_incidents'])) -}}
80+
{{ "{:>{width}}".format(fmt(data['total_incidents']), width=ind_issues_space) -}}
7481
{% endfor %}
75-
{% endfor %} ─────────────────────────────────────────────────────────────────────────
76-
{{ "{:<12}".format(" Total") -}}
77-
{{ "{:<4}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_existing_issues') | sum)) -}} +{{" "}}
78-
{{- "{:<4}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_new_issues') | sum)) -}} ={{" "}}
79-
{{- "{:<6}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_total_issues') | sum)) -}}
80-
{{ fmt(build_incidents_by_origin.values() | map(attribute='total_incidents') | sum) }}
82+
{% endfor %} ───────────────────────────────────────────────────────────────────────────
83+
{{ "{:<{width}}".format(" Total", width=origin_space) -}}
84+
{{ "{:>{width}}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_existing_issues') | sum) + " +", width=known_reg_space) }}
85+
{{- "{:>{width}}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_new_issues') | sum) + " =", width=new_reg_space) }}
86+
{{- "{:>{width}}".format(fmt(build_incidents_by_origin.values() | map(attribute='n_total_issues') | sum), width=total_reg_space) -}}
87+
{{ "{:>{width}}".format(fmt(build_incidents_by_origin.values() | map(attribute='total_incidents') | sum), width=affected_space) }}
8188
{%- else %} No build regressions to show in this period. {%- endif %}
8289

8390

backend/kernelCI_app/tests/unitTests/commands/fixtures/metrics_notifications_example.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ KernelCI Metrics Summary
1616
-----------------
1717
A "regression" is defined as a reported problem affecting 0 or multiple builds.
1818

19-
Origin Regressions Affected Affected builds by top issues
20-
(known + new) Builds (total) #1 #2 #3
21-
─────────────────────────────────────────────────────────────────────────
22-
maestro 1 + 1 = 2 70 50 20
23-
redhat 1 + 0 = 1 5 5
24-
─────────────────────────────────────────────────────────────────────────
25-
Total 2 + 1 = 3 75
19+
Origin Regressions Affected Affected builds by top issues
20+
(known + new) Builds (total) #1 #2 #3
21+
───────────────────────────────────────────────────────────────────────────
22+
maestro 1 + 1 = 2 70 50 20
23+
redhat 1 + 0 = 1 5 5
24+
───────────────────────────────────────────────────────────────────────────
25+
Total 2 + 1 = 3 75
2626

2727

2828
TOP REGRESSIONS PER ORIGIN

0 commit comments

Comments
 (0)