Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Move footer into lambda configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishaalkapoor committed Nov 21, 2018
1 parent 804a6a0 commit b078255
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion reporting/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions reporting/utils/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
REPORT_EMAIL_FROM = '[email protected]'
REPORT_MAILLIST = '[email protected]'

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.
Expand All @@ -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 = '<i>Note: Values are averaged over the last 7 days.</i>'
html = "{}<br/><br/>{}".format(report_html, EMAIL_FOOTNOTE)
html = "{}<br/><br/>{}".format(report_html, footnotes)
logging.info("Sending e-mail report.")
ses = boto3.client('ses')
response = ses.send_email(
Expand Down

0 comments on commit b078255

Please sign in to comment.