This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_email_html(tickets): | |
body_html = [ | |
'The following tickets are open or in code review. Please ensure their status and remaining hours are up to date.', | |
'<br><br>', | |
'<table style="border-spacing: 10px">', | |
'<tr><td>Ticket Number</td><td>Status</td><td>Time Remaining</td><td>Description</td></tr>' | |
] | |
for ticket in tickets: | |
body_html.append('<tr>') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
for issue in jira_data['issues']: | |
ticket = get_ticket_data(issue) | |
assignee = issue['fields']['assignee']['emailAddress'] | |
if assignee not in assignments: | |
assignments[assignee] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_ticket_data(issue): | |
fields = issue['fields'] | |
ticket = {} | |
ticket['key'] = issue['key'] | |
ticket['summary'] = fields['summary'] | |
ticket['status'] = fields['status']['name'] | |
if fields['timeestimate'] is None: | |
ticket['timeestimate'] = 0 | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_jira_assigments(): | |
""" | |
Gets data from Jira API and builds list of tickets by assignee | |
""" | |
username = os.environ['JIRA_USERNAME'] | |
password = os.environ['JIRA_PASSWORD'] | |
params = { | |
"jql": 'status in ("IN PROGRESS", "CODE REVIEW") AND assignee != Unassigned', | |
"startAt": 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lambda_handler(event, context): | |
jira_assignments = get_jira_assigments() | |
for email_address, tickets in jira_assignments.items(): | |
body_html = generate_email_html(tickets) | |
body_text_only = generate_email_text(tickets) | |
send_reminder_email(email_address, body_html, body_text_only) |