aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorparnic <github@parnic.com>2022-08-08 15:03:58 -0500
committerGitHub <noreply@github.com>2022-08-08 22:03:58 +0200
commit0066bc511321d393065fb17a0c91f15b8e483fe5 (patch)
tree2b6d83ce6d86fc0f7dce1e1b01f92ac708cc4a66 /models
parent2b101994a6f4724500908226f9a55816062f1da6 (diff)
downloadgitea-0066bc511321d393065fb17a0c91f15b8e483fe5.tar.gz
gitea-0066bc511321d393065fb17a0c91f15b8e483fe5.zip
Add issue filter for Author (#20578)
This adds a new filter option on the issues and pulls pages to filter by the author/poster/creator of the issue or PR
Diffstat (limited to 'models')
-rw-r--r--models/repo/user_repo.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/models/repo/user_repo.go b/models/repo/user_repo.go
index 71e0c57550..6c0a241dc5 100644
--- a/models/repo/user_repo.go
+++ b/models/repo/user_repo.go
@@ -170,3 +170,15 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64)
users := make([]*user_model.User, 0, 8)
return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users)
}
+
+// GetIssuePosters returns all users that have authored an issue/pull request for the given repository
+func GetIssuePosters(ctx context.Context, repo *Repository, isPull bool) ([]*user_model.User, error) {
+ users := make([]*user_model.User, 0, 8)
+ cond := builder.In("`user`.id",
+ builder.Select("poster_id").From("issue").Where(
+ builder.Eq{"repo_id": repo.ID}.
+ And(builder.Eq{"is_pull": isPull}),
+ ).GroupBy("poster_id"),
+ )
+ return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users)
+}