diff options
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go index 90d57763..89c72f48 100644 --- a/models/issue.go +++ b/models/issue.go @@ -980,6 +980,23 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { return issues, nil } +// GetParticipantsByIssueID returns all users who are participated in comments of an issue. +func GetParticipantsByIssueID(issueID int64) ([]*User, error) { + userIDs := make([]int64, 0, 5) + if err := x.Table("comment").Cols("poster_id"). + Where("issue_id = ?", issueID). + Distinct("poster_id"). + Find(&userIDs); err != nil { + return nil, fmt.Errorf("get poster IDs: %v", err) + } + if len(userIDs) == 0 { + return nil, nil + } + + users := make([]*User, 0, len(userIDs)) + return users, x.In("id", userIDs).Find(&users) +} + // .___ ____ ___ // | | ______ ________ __ ____ | | \______ ___________ // | |/ ___// ___/ | \_/ __ \| | / ___// __ \_ __ \ |