|
|
|
@ -272,21 +272,22 @@ func convertGithubReactions(reactions *github.Reactions) *base.Reactions {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetIssues returns issues according start and limit
|
|
|
|
|
func (g *GithubDownloaderV3) GetIssues(start, limit int) ([]*base.Issue, error) {
|
|
|
|
|
var perPage = 100
|
|
|
|
|
func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool, error) {
|
|
|
|
|
opt := &github.IssueListByRepoOptions{
|
|
|
|
|
Sort: "created",
|
|
|
|
|
Direction: "asc",
|
|
|
|
|
State: "all",
|
|
|
|
|
ListOptions: github.ListOptions{
|
|
|
|
|
PerPage: perPage,
|
|
|
|
|
Page: page,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
var allIssues = make([]*base.Issue, 0, limit)
|
|
|
|
|
for {
|
|
|
|
|
issues, resp, err := g.client.Issues.ListByRepo(g.ctx, g.repoOwner, g.repoName, opt)
|
|
|
|
|
|
|
|
|
|
var allIssues = make([]*base.Issue, 0, perPage)
|
|
|
|
|
|
|
|
|
|
issues, _, err := g.client.Issues.ListByRepo(g.ctx, g.repoOwner, g.repoName, opt)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("error while listing repos: %v", err)
|
|
|
|
|
return nil, false, fmt.Errorf("error while listing repos: %v", err)
|
|
|
|
|
}
|
|
|
|
|
for _, issue := range issues {
|
|
|
|
|
if issue.IsPullRequest() {
|
|
|
|
@ -327,16 +328,9 @@ func (g *GithubDownloaderV3) GetIssues(start, limit int) ([]*base.Issue, error)
|
|
|
|
|
Closed: issue.ClosedAt,
|
|
|
|
|
IsLocked: *issue.Locked,
|
|
|
|
|
})
|
|
|
|
|
if len(allIssues) >= limit {
|
|
|
|
|
return allIssues, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if resp.NextPage == 0 {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
opt.Page = resp.NextPage
|
|
|
|
|
}
|
|
|
|
|
return allIssues, nil
|
|
|
|
|
|
|
|
|
|
return allIssues, len(issues) < perPage, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetComments returns comments according issueNumber
|
|
|
|
@ -379,19 +373,20 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er
|
|
|
|
|
return allComments, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetPullRequests returns pull requests according start and limit
|
|
|
|
|
func (g *GithubDownloaderV3) GetPullRequests(start, limit int) ([]*base.PullRequest, error) {
|
|
|
|
|
// GetPullRequests returns pull requests according page and perPage
|
|
|
|
|
func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullRequest, error) {
|
|
|
|
|
opt := &github.PullRequestListOptions{
|
|
|
|
|
Sort: "created",
|
|
|
|
|
Direction: "asc",
|
|
|
|
|
State: "all",
|
|
|
|
|
ListOptions: github.ListOptions{
|
|
|
|
|
PerPage: 100,
|
|
|
|
|
PerPage: perPage,
|
|
|
|
|
Page: page,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
var allPRs = make([]*base.PullRequest, 0, 100)
|
|
|
|
|
for {
|
|
|
|
|
prs, resp, err := g.client.PullRequests.List(g.ctx, g.repoOwner, g.repoName, opt)
|
|
|
|
|
var allPRs = make([]*base.PullRequest, 0, perPage)
|
|
|
|
|
|
|
|
|
|
prs, _, err := g.client.PullRequests.List(g.ctx, g.repoOwner, g.repoName, opt)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("error while listing repos: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -462,14 +457,7 @@ func (g *GithubDownloaderV3) GetPullRequests(start, limit int) ([]*base.PullRequ
|
|
|
|
|
},
|
|
|
|
|
PatchURL: *pr.PatchURL,
|
|
|
|
|
})
|
|
|
|
|
if len(allPRs) >= limit {
|
|
|
|
|
return allPRs, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if resp.NextPage == 0 {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
opt.Page = resp.NextPage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return allPRs, nil
|
|
|
|
|
}
|
|
|
|
|