Skip to content

Commit

Permalink
add assignments to the todo/daily report (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato authored and jwilander committed Aug 9, 2018
1 parent 95ac1b1 commit e61ad1f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ func (p *Plugin) GetToDo(ctx context.Context, username string, githubClient *git
return "", err
}

yourAssignments, _, err := githubClient.Search.Issues(ctx, getYourAssigneeSearchQuery(username, p.GitHubOrg), &github.SearchOptions{})
if err != nil {
return "", err
}

text := "##### Unread Messages\n"

notificationCount := 0
Expand Down Expand Up @@ -318,6 +323,18 @@ func (p *Plugin) GetToDo(ctx context.Context, username string, githubClient *git
}
}

text += "##### Your Assigments\n"

if yourAssignments.GetTotal() == 0 {
text += "You have don't have any assignments.\n"
} else {
text += fmt.Sprintf("You have %v assignments:\n", yourAssignments.GetTotal())

for _, assign := range yourAssignments.Issues {
text += fmt.Sprintf("* %v\n", assign.GetHTMLURL())
}
}

return text, nil
}

Expand Down
4 changes: 4 additions & 0 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func getYourPrsSearchQuery(username, org string) string {
return bulidSearchQuery("is:pr is:open author:%v archived:false %v", username, org)
}

func getYourAssigneeSearchQuery(username, org string) string {
return bulidSearchQuery("is:open assignee:%v archived:false %v", username, org)
}

func bulidSearchQuery(query, username, org string) string {
orgField := ""
if len(org) != 0 {
Expand Down

0 comments on commit e61ad1f

Please sign in to comment.