aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_list.go
diff options
context:
space:
mode:
authorkolaente <konrad@kola-entertainments.de>2018-05-09 18:29:04 +0200
committerLauris BH <lauris@nix.lv>2018-05-09 19:29:04 +0300
commit95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd (patch)
treeebfeb5b898f72fc57ac1fe9680374fdb4bc91aeb /models/issue_list.go
parent238a997ec0b5d3e3bed0e55edcacebb44f86d373 (diff)
downloadgitea-95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd.tar.gz
gitea-95f2e2b57beedcdeb2b9623dc86e26f252fdd7bd.zip
Multiple assignees (#3705)
Diffstat (limited to 'models/issue_list.go')
-rw-r--r--models/issue_list.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/models/issue_list.go b/models/issue_list.go
index 01a1a15f44..05130a6eef 100644
--- a/models/issue_list.go
+++ b/models/issue_list.go
@@ -154,38 +154,38 @@ func (issues IssueList) loadMilestones(e Engine) error {
return nil
}
-func (issues IssueList) getAssigneeIDs() []int64 {
- var ids = make(map[int64]struct{}, len(issues))
- for _, issue := range issues {
- if _, ok := ids[issue.AssigneeID]; !ok {
- ids[issue.AssigneeID] = struct{}{}
- }
- }
- return keysInt64(ids)
-}
-
func (issues IssueList) loadAssignees(e Engine) error {
- assigneeIDs := issues.getAssigneeIDs()
- if len(assigneeIDs) == 0 {
+ if len(issues) == 0 {
return nil
}
- assigneeMaps := make(map[int64]*User, len(assigneeIDs))
- err := e.
- In("id", assigneeIDs).
- Find(&assigneeMaps)
+ type AssigneeIssue struct {
+ IssueAssignee *IssueAssignees `xorm:"extends"`
+ Assignee *User `xorm:"extends"`
+ }
+
+ var assignees = make(map[int64][]*User, len(issues))
+ rows, err := e.Table("issue_assignees").
+ Join("INNER", "user", "`user`.id = `issue_assignees`.assignee_id").
+ In("`issue_assignees`.issue_id", issues.getIssueIDs()).
+ Rows(new(AssigneeIssue))
if err != nil {
return err
}
+ defer rows.Close()
- for _, issue := range issues {
- if issue.AssigneeID <= 0 {
- continue
- }
- var ok bool
- if issue.Assignee, ok = assigneeMaps[issue.AssigneeID]; !ok {
- issue.Assignee = NewGhostUser()
+ for rows.Next() {
+ var assigneeIssue AssigneeIssue
+ err = rows.Scan(&assigneeIssue)
+ if err != nil {
+ return err
}
+
+ assignees[assigneeIssue.IssueAssignee.IssueID] = append(assignees[assigneeIssue.IssueAssignee.IssueID], assigneeIssue.Assignee)
+ }
+
+ for _, issue := range issues {
+ issue.Assignees = assignees[issue.ID]
}
return nil
}