From 23bdf0356ab040e333ed2502213a92afbc390b4b Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Mon, 9 Dec 2024 15:44:16 +0100 Subject: [PATCH] feat: health rating color in email (#8943) --- src/lib/services/email-service.test.ts | 1 + src/lib/services/email-service.ts | 10 ++++++++++ .../productivity-report.html.mustache | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/services/email-service.test.ts b/src/lib/services/email-service.test.ts index e424c6be2b1a..1ee62d8d9d24 100644 --- a/src/lib/services/email-service.test.ts +++ b/src/lib/services/email-service.test.ts @@ -174,6 +174,7 @@ test('Can send productivity report email', async () => { expect(content.html.includes(`Productivity Report`)).toBe(true); expect(content.html.includes(`localhost/insights`)).toBe(true); expect(content.html.includes(`localhost/profile`)).toBe(true); + expect(content.html.includes(`#b0d182`)).toBe(true); expect(content.text.includes(`localhost/insights`)).toBe(true); expect(content.text.includes(`localhost/profile`)).toBe(true); }); diff --git a/src/lib/services/email-service.ts b/src/lib/services/email-service.ts index e7e6bcacb543..f9fd56cb5981 100644 --- a/src/lib/services/email-service.ts +++ b/src/lib/services/email-service.ts @@ -542,6 +542,16 @@ export class EmailService { userEmail, ...metrics, unleashUrl: this.config.server.unleashUrl, + healthColor() { + const healthRating = this.health; + const healthColor = + healthRating >= 0 && healthRating <= 24 + ? '#d93644' + : healthRating >= 25 && healthRating <= 74 + ? '#ffc46f' + : '#b0d182'; + return healthColor; + }, }; const template = 'productivity-report'; diff --git a/src/mailtemplates/productivity-report/productivity-report.html.mustache b/src/mailtemplates/productivity-report/productivity-report.html.mustache index 4147acde9435..5b8ed032c435 100644 --- a/src/mailtemplates/productivity-report/productivity-report.html.mustache +++ b/src/mailtemplates/productivity-report/productivity-report.html.mustache @@ -27,7 +27,7 @@
- {{health}}%
+ {{health}}%
your instance health