diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/issues/pull.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go index 4194df2e3d..014fcd9fd0 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -430,6 +430,21 @@ func (pr *PullRequest) GetGitHeadBranchRefName() string { return fmt.Sprintf("%s%s", git.BranchPrefix, pr.HeadBranch) } +// GetReviewCommentsCount returns the number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR) +func (pr *PullRequest) GetReviewCommentsCount(ctx context.Context) int { + opts := FindCommentsOptions{ + Type: CommentTypeReview, + IssueID: pr.IssueID, + } + conds := opts.ToConds() + + count, err := db.GetEngine(ctx).Where(conds).Count(new(Comment)) + if err != nil { + return 0 + } + return int(count) +} + // IsChecking returns true if this pull request is still checking conflict. func (pr *PullRequest) IsChecking() bool { return pr.Status == PullRequestStatusChecking |