From b0782557a2dbdd6a3421169dc8a3fa23cd134ad4 Mon Sep 17 00:00:00 2001 From: Vishaal Kapoor Date: Wed, 21 Nov 2018 14:58:06 -0800 Subject: [PATCH] Move footer into lambda configuration. --- reporting/lambda_handler.py | 3 ++- reporting/utils/email.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/reporting/lambda_handler.py b/reporting/lambda_handler.py index 2ac3798..c8ce9a8 100644 --- a/reporting/lambda_handler.py +++ b/reporting/lambda_handler.py @@ -56,7 +56,8 @@ def lambda_handler(event, context): logging.info('Emailing report.') EMAIL = os.environ['EMAIL'] - email_report(report_html, EMAIL) + FOOTNOTES = os.environ['FOOTNOTES'] # allows passing in non-public information. + email_report(report_html, EMAIL, footnotes=FOOTNOTES) return { "statusCode": 200, diff --git a/reporting/utils/email.py b/reporting/utils/email.py index be4e0a4..4136d4e 100644 --- a/reporting/utils/email.py +++ b/reporting/utils/email.py @@ -25,7 +25,7 @@ REPORT_EMAIL_FROM = 'vishaalk@amazon.com' REPORT_MAILLIST = 'benchmark-ai-reports@amazon.com' -def email_report(report_html, email_addr=REPORT_MAILLIST): +def email_report(report_html, email_addr=REPORT_MAILLIST, footnotes=''): """ Send a Benchmark.AI report to an e-mail address TODO(vishaalk): Validate the e-mail address format. @@ -34,12 +34,14 @@ def email_report(report_html, email_addr=REPORT_MAILLIST): ---------- report_html : str the report formatted in HTML - email_addr : string + email_addr : str the e-mail address to send the report to + footnotes : str + any additional information to append to the information (e.g. non-public links). This should + be formatted with HTML tags. """ - EMAIL_FOOTNOTE = 'Note: Values are averaged over the last 7 days.' - html = "{}

{}".format(report_html, EMAIL_FOOTNOTE) + html = "{}

{}".format(report_html, footnotes) logging.info("Sending e-mail report.") ses = boto3.client('ses') response = ses.send_email(