MCPcopy
hub / github.com/mislav/hub / FetchIssues

Method FetchIssues

github/client.go:686–723  ·  view source on GitHub ↗
(project *Project, filterParams map[string]interface{}, limit int, filter func(*Issue) bool)

Source from the content-addressed store, hash-verified

684}
685
686func (client *Client) FetchIssues(project *Project, filterParams map[string]interface{}, limit int, filter func(*Issue) bool) (issues []Issue, err error) {
687 api, err := client.simpleApi()
688 if err != nil {
689 return
690 }
691
692 path := fmt.Sprintf("repos/%s/%s/issues?per_page=%d", project.Owner, project.Name, perPage(limit, 100))
693 if filterParams != nil {
694 path = addQuery(path, filterParams)
695 }
696
697 issues = []Issue{}
698 var res *simpleResponse
699
700 for path != "" {
701 res, err = api.Get(path)
702 if err = checkStatus(200, "fetching issues", res, err); err != nil {
703 return
704 }
705 path = res.Link("next")
706
707 issuesPage := []Issue{}
708 if err = res.Unmarshal(&issuesPage); err != nil {
709 return
710 }
711 for _, issue := range issuesPage {
712 if filter == nil || filter(&issue) {
713 issues = append(issues, issue)
714 if limit > 0 && len(issues) == limit {
715 path = ""
716 break
717 }
718 }
719 }
720 }
721
722 return
723}
724
725func (client *Client) FetchIssue(project *Project, number string) (issue *Issue, err error) {
726 api, err := client.simpleApi()

Callers 1

listIssuesFunction · 0.95

Calls 7

simpleApiMethod · 0.95
LinkMethod · 0.95
UnmarshalMethod · 0.95
perPageFunction · 0.85
addQueryFunction · 0.85
checkStatusFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected