Skip to content

Commit 69dadac

Browse files
committed
(feat): Added machine to email reports
1 parent 5499504 commit 69dadac

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/job/email_report.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ def _process(self):
2828
SELECT r.name,
2929
(SELECT array_agg(t.name) FROM unnest(r.category_ids) as elements
3030
LEFT JOIN categories as t on t.id = elements) as categories,
31+
m.description as machine_description, m.id as machine_id,
3132
r.uri, r.filename, r.branch, r.usage_scenario_variables, r.created_at
3233
FROM runs r
34+
LEFT JOIN machines m ON m.id = r.machine_id
3335
WHERE r.id = %s
34-
GROUP BY r.id
36+
GROUP BY r.id, m.id
3537
''',
3638
params=(self._run_id, ),
3739
fetch_mode='dict')
@@ -112,6 +114,7 @@ def replace_variables(template, run_id, run):
112114
template = template.replace('{{__GMT_RUN_REPO__}}', run['uri'])
113115
template = template.replace('{{__GMT_RUN_FILENAME__}}', run['filename'])
114116
template = template.replace('{{__GMT_RUN_BRANCH__}}', run['branch'])
117+
template = template.replace('{{__GMT_RUN_MACHINE__}}', f"{run['machine_description']} ({run['machine_id']})")
115118
template = template.replace('{{__GMT_RUN_DATE__}}', datetime.fromisoformat(str(run['created_at'])).astimezone().strftime("%Y-%m-%d %H:%M %z"))
116119

117120
# optionals

templates/emails/email_report_general.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ <h1>Green Metrics Tool Report</h1>
5454
<p>Repository: <strong>{{__GMT_RUN_REPO__}}</strong></p>
5555
<p>Filename: <strong>{{__GMT_RUN_FILENAME__}}</strong></p>
5656
<p>Branch: <strong>{{__GMT_RUN_BRANCH__}}</strong></p>
57+
<p>Machine: <strong>{{__GMT_RUN_MACHINE__}}</strong></p>
5758
<p>Report Date: <strong>{{__GMT_RUN_DATE__}}</strong></p>
5859
</div>
5960
<br>

templates/emails/email_report_general.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Run Name: {{__GMT_RUN_NAME__}}
44
Repository: {{__GMT_RUN_REPO__}}
55
Filename: {{__GMT_RUN_FILENAME__}}
66
Branch: {{__GMT_RUN_BRANCH__}}
7+
Machine: {{__GMT_RUN_MACHINE__}}
78
Report Date: {{__GMT_RUN_DATE__}}
89

910

0 commit comments

Comments
 (0)