From db6a288b4d48a7f64a7d7009e861c4a393c48ca4 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 15 Sep 2021 17:30:34 +0800 Subject: [PATCH 1/2] Fix bug of migrate comments which only fetch one page --- modules/migrations/github.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index 54af10d116aa9..4e88bbeae7f57 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -535,6 +535,8 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, if err != nil { return nil, false, fmt.Errorf("error while listing repos: %v", err) } + var isEnd = resp.NextPage == 0 + log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments)) g.rate = &resp.Rate for _, comment := range comments { @@ -575,7 +577,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, }) } - return allComments, len(allComments) < perPage, nil + return allComments, isEnd, nil } // GetPullRequests returns pull requests according page and perPage From f70414c1ffc851c19ee781635777eea59af51d2b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 15 Sep 2021 17:42:45 +0800 Subject: [PATCH 2/2] add next page to trace --- modules/migrations/github.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index 4e88bbeae7f57..97e1b672accdc 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -521,6 +521,9 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, created = "created" asc = "asc" ) + if perPage > g.maxPerPage { + perPage = g.maxPerPage + } opt := &github.IssueListCommentsOptions{ Sort: &created, Direction: &asc, @@ -537,7 +540,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment, } var isEnd = resp.NextPage == 0 - log.Trace("Request get comments %d/%d, but in fact get %d", perPage, page, len(comments)) + log.Trace("Request get comments %d/%d, but in fact get %d, next page is %d", perPage, page, len(comments), resp.NextPage) g.rate = &resp.Rate for _, comment := range comments { // get reactions