some refactors for issue and comments (#2419)

This commit is contained in:
Lunny Xiao 2017-08-30 12:31:33 +08:00 committed by Lauris BH
parent edc817a1dc
commit 5de94a67cf
4 changed files with 30 additions and 14 deletions

View file

@ -1206,8 +1206,12 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
// GetParticipantsByIssueID returns all users who are participated in comments of an issue.
func GetParticipantsByIssueID(issueID int64) ([]*User, error) {
return getParticipantsByIssueID(x, issueID)
}
func getParticipantsByIssueID(e Engine, issueID int64) ([]*User, error) {
userIDs := make([]int64, 0, 5)
if err := x.Table("comment").Cols("poster_id").
if err := e.Table("comment").Cols("poster_id").
Where("issue_id = ?", issueID).
And("type = ?", CommentTypeComment).
Distinct("poster_id").
@ -1219,7 +1223,7 @@ func GetParticipantsByIssueID(issueID int64) ([]*User, error) {
}
users := make([]*User, 0, len(userIDs))
return users, x.In("id", userIDs).Find(&users)
return users, e.In("id", userIDs).Find(&users)
}
// UpdateIssueMentions extracts mentioned people from content and