Skip to content

Commit c9639e1

Browse files
committed
add functions to get IssueAuthors per repo
1 parent 4cdecac commit c9639e1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

models/repo.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,24 @@ func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
616616
return users, nil
617617
}
618618

619+
func (repo *Repository) getIssueAuthors(e Engine) (authors []*User, err error) {
620+
err = e.Where("issue.repo_id = ?", repo.ID).
621+
Join("LEFT", "user", "user.id = issue.poster_id").OrderBy("user.id").
622+
GroupBy("user.id").Select("user.id, user.name, user.full_name").Find(authors)
623+
624+
return
625+
}
626+
619627
// GetAssignees returns all users that have write access and can be assigned to issues
620628
// of the repository,
621629
func (repo *Repository) GetAssignees() (_ []*User, err error) {
622630
return repo.getAssignees(x)
623631
}
624632

633+
func (repo *Repository) GetIssueAuthors() (_ []*User, err error) {
634+
return repo.getIssueAuthors(x)
635+
}
636+
625637
// GetMilestoneByID returns the milestone belongs to repository by given ID.
626638
func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
627639
return GetMilestoneByRepoID(repo.ID, milestoneID)

0 commit comments

Comments
 (0)