@@ -2,7 +2,7 @@ import { SendEmailCommand } from "@aws-sdk/client-ses";
22import { type ABExpiryChecks } from "./checkExpiry.ts" ;
33import { sesClient } from "./sesClient.ts" ;
44
5- const getEmailBodyHtml = ( abTestExpiryChecks : ABExpiryChecks ) => {
5+ const getEmailBodyHtml = ( abTestExpiryChecks : ABExpiryChecks ) : string => {
66 const tableConfig : Record <
77 keyof ABExpiryChecks ,
88 { title : string ; accentColour : string }
@@ -21,7 +21,7 @@ const getEmailBodyHtml = (abTestExpiryChecks: ABExpiryChecks) => {
2121 } ,
2222 } ;
2323
24- const getTestsTableHtml = ( group : keyof typeof tableConfig ) => {
24+ const getTestsTableHtml = ( group : keyof typeof tableConfig ) : string => {
2525 const config = tableConfig [ group ] ;
2626 return `
2727 <h2 style="margin-bottom: 0.5rem; font-size: 1.2rem; color: ${
@@ -38,13 +38,15 @@ const getEmailBodyHtml = (abTestExpiryChecks: ABExpiryChecks) => {
3838 <th>Owners</th>
3939 </thead>
4040 <tbody style="text-align: center;">
41- ${ abTestExpiryChecks [ group ] . map ( ( test ) => {
42- return `<tr style="padding: 10px;">
41+ ${ abTestExpiryChecks [ group ]
42+ . map ( ( test ) => {
43+ return `<tr style="padding: 10px;">
4344 <td><strong>${ test . name } </strong></td>
4445 <td>${ test . expirationDate } </td>
4546 <td>${ test . owners . join ( "<br/>" ) } </td>
4647 </tr>` ;
47- } ) }
48+ } )
49+ . join ( "<br />" ) }
4850 </tbody>
4951 </table>` ;
5052 } ;
@@ -53,16 +55,16 @@ const getEmailBodyHtml = (abTestExpiryChecks: ABExpiryChecks) => {
5355 <div style="margin:auto; margin:10px; font-family: sans-serif;">
5456 <h1 style="font-size: 1.4rem">AB Tests Expiry Reminder</h1>
5557
56- ${ ! ! abTestExpiryChecks [ "expired" ] . length ? getTestsTableHtml ( "expired" ) : "" }
58+ ${ abTestExpiryChecks [ "expired" ] . length ? getTestsTableHtml ( "expired" ) : "" }
5759
5860 ${
59- ! ! abTestExpiryChecks [ "within1Day" ] . length
61+ abTestExpiryChecks [ "within1Day" ] . length
6062 ? getTestsTableHtml ( "within1Day" )
6163 : ""
6264 }
6365
6466 ${
65- ! ! abTestExpiryChecks [ "within2Days" ] . length
67+ abTestExpiryChecks [ "within2Days" ] . length
6668 ? getTestsTableHtml ( "within2Days" )
6769 : ""
6870 }
@@ -84,22 +86,34 @@ const getEmailBodyPlainText = (abTestsByExpiryDate: ABExpiryChecks): string => {
8486 AB Tests Expiry Reminder
8587
8688 Expired:
87- ${ abTestsByExpiryDate . expired . map (
88- ( test ) =>
89- `${ test . name } expired ${ test . expirationDate } . Owners: ${ test . owners } ` ,
90- ) }
89+ ${ abTestsByExpiryDate . expired
90+ . map (
91+ ( test ) =>
92+ `${ test . name } expired ${
93+ test . expirationDate
94+ } . Owners: ${ test . owners . join ( ", " ) } `,
95+ )
96+ . join ( "\n" ) }
9197
9298 Expiring today (at 23:59):
93- ${ abTestsByExpiryDate . within1Day . map (
94- ( test ) =>
95- `${ test . name } expired ${ test . expirationDate } . Owners: ${ test . owners } ` ,
96- ) }
99+ ${ abTestsByExpiryDate . within1Day
100+ . map (
101+ ( test ) =>
102+ `${ test . name } expired ${
103+ test . expirationDate
104+ } . Owners: ${ test . owners . join ( ", " ) } `,
105+ )
106+ . join ( "\n" ) }
97107
98108 Expiring tomorrow (at 23:59):
99- ${ abTestsByExpiryDate . within2Days . map (
100- ( test ) =>
101- `${ test . name } expired ${ test . expirationDate } . Owners: ${ test . owners } ` ,
102- ) }
109+ ${ abTestsByExpiryDate . within2Days
110+ . map (
111+ ( test ) =>
112+ `${ test . name } expired ${
113+ test . expirationDate
114+ } . Owners: ${ test . owners . join ( ", " ) } `,
115+ )
116+ . join ( "\n" ) }
103117
104118 If you are not ready to remove a test yet but are happy to leave it expired for now, please turn it OFF in the code (https://github.com/guardian/dotcom-rendering/blob/main/ab-testing/config/abTests.ts)
105119
0 commit comments