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
This commit is contained in:
parnic 2022-08-08 15:03:58 -05:00 committed by GitHub
parent 2b101994a6
commit 0066bc5113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 38 deletions

View file

@ -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)
}