summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-05-26 12:53:42 +0800
committerGitHub <noreply@github.com>2024-05-26 12:53:42 +0800
commit1171b24d52f58a6f222f040936153222d32e03b4 (patch)
tree446c68b7cacc441c560277853d5bcf71d0206702 /models
parent7d56ee3c0f7fae34131a82d44599a4caa09ad0ec (diff)
downloadgitea-1171b24d52f58a6f222f040936153222d32e03b4.tar.gz
gitea-1171b24d52f58a6f222f040936153222d32e03b4.zip
Make gitea webhooks openproject compatible (#28435) (#31081)
Backport #28435 by Chief-Detektor Co-authored-by: André Rosenhammer <andre.rosenhammer@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/issues/pull.go15
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