def get_incidents(repo, issues):
# loop over all issues in the past 90 days to get current and past incidents
incidents = []
collaborators = get_collaborators(repo=repo)
for issue in issues:
labels = issue.get_labels()
affected_systems = sorted(iter_systems(labels))
severity = get_severity(labels)
# make sure that non-labeled issues are not displayed
if not affected_systems or severity is None:
continue
# make sure that the user that created the issue is a collaborator
if issue.user.login not in collaborators:
continue
# create an incident
incident = {
"created": issue.created_at,
"title": issue.title,
"systems": affected_systems,
"severity": severity,
"closed": issue.state == "closed",
"body": markdown2.markdown(issue.body),
"updates": []
}
for comment in issue.get_comments():
# add comments by collaborators only
if comment.user.login in collaborators:
incident["updates"].append({
"created": comment.created_at,
"body": markdown2.markdown(comment.body)
})
incidents.append(incident)
# sort incidents by date
return sorted(incidents, key=lambda i: i["created"], reverse=True)
评论列表
文章目录