common: refactor IsReviewed()
This commit is contained in:
parent
77bdf7649a
commit
881cba862f
@ -297,17 +297,15 @@ func (gitea *GiteaTransport) RequestReviews(pr *models.PullRequest, reviewer str
|
|||||||
func (gitea *GiteaTransport) IsReviewed(pr *models.PullRequest) (bool, error) {
|
func (gitea *GiteaTransport) IsReviewed(pr *models.PullRequest) (bool, error) {
|
||||||
// TODO: get review from project git
|
// TODO: get review from project git
|
||||||
reviewers := pr.RequestedReviewers
|
reviewers := pr.RequestedReviewers
|
||||||
var page, limit int64
|
var page int64
|
||||||
var reviews []*models.PullReview
|
reviews := make([]*models.PullReview, 0, 10)
|
||||||
page = 0
|
|
||||||
limit = 20
|
|
||||||
for {
|
for {
|
||||||
|
page++
|
||||||
res, err := gitea.client.Repository.RepoListPullReviews(
|
res, err := gitea.client.Repository.RepoListPullReviews(
|
||||||
repository.NewRepoListPullReviewsParams().
|
repository.NewRepoListPullReviewsParams().
|
||||||
WithOwner(pr.Base.Repo.Owner.UserName).
|
WithOwner(pr.Base.Repo.Owner.UserName).
|
||||||
WithRepo(pr.Base.Repo.Name).
|
WithRepo(pr.Base.Repo.Name).
|
||||||
WithPage(&page).
|
WithPage(&page),
|
||||||
WithLimit(&limit),
|
|
||||||
gitea.transport.DefaultAuthentication)
|
gitea.transport.DefaultAuthentication)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -315,15 +313,8 @@ func (gitea *GiteaTransport) IsReviewed(pr *models.PullRequest) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if res.IsSuccess() {
|
if res.IsSuccess() {
|
||||||
r := res.Payload
|
reviews = append(reviews, res.Payload...)
|
||||||
|
if len(res.Payload) < 10 {
|
||||||
if reviews == nil {
|
|
||||||
reviews = r
|
|
||||||
} else {
|
|
||||||
reviews = append(reviews, r...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(r) < int(limit) {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user