summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/models/issue.go b/models/issue.go
index 9d081471a7..a8149b123d 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -155,6 +155,17 @@ func (issue *Issue) loadPullRequest(e Engine) (err error) {
return nil
}
+func (issue *Issue) loadComments(e Engine) (err error) {
+ if issue.Comments != nil {
+ return nil
+ }
+ issue.Comments, err = findComments(e, FindCommentsOptions{
+ IssueID: issue.ID,
+ Type: CommentTypeUnknown,
+ })
+ return err
+}
+
func (issue *Issue) loadAttributes(e Engine) (err error) {
if err = issue.loadRepo(e); err != nil {
return
@@ -191,14 +202,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) {
}
}
- if issue.Comments == nil {
- issue.Comments, err = findComments(e, FindCommentsOptions{
- IssueID: issue.ID,
- Type: CommentTypeUnknown,
- })
- if err != nil {
- return fmt.Errorf("getCommentsByIssueID [%d]: %v", issue.ID, err)
- }
+ if err = issue.loadComments(e); err != nil {
+ return
}
return nil
@@ -577,7 +582,7 @@ func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
if _, err := e.Id(issue.ID).Cols(cols...).Update(issue); err != nil {
return err
}
- UpdateIssueIndexer(issue)
+ UpdateIssueIndexer(issue.ID)
return nil
}
@@ -907,8 +912,6 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
return err
}
- UpdateIssueIndexer(opts.Issue)
-
if len(opts.Attachments) > 0 {
attachments, err := getAttachmentsByUUIDs(e, opts.Attachments)
if err != nil {
@@ -947,6 +950,8 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
return fmt.Errorf("Commit: %v", err)
}
+ UpdateIssueIndexer(issue.ID)
+
if err = NotifyWatchers(&Action{
ActUserID: issue.Poster.ID,
ActUser: issue.Poster,
@@ -1448,7 +1453,7 @@ func updateIssue(e Engine, issue *Issue) error {
if err != nil {
return err
}
- UpdateIssueIndexer(issue)
+ UpdateIssueIndexer(issue.ID)
return nil
}