From 0f6dc411dfc2bf85511b533c4055aa0c95bf54b1 Mon Sep 17 00:00:00 2001
From: Ethan Koenig <ethantkoenig@gmail.com>
Date: Mon, 20 Nov 2017 21:28:22 -0800
Subject: [PATCH] Remove unnecessary IssueList attribute loads (#2936)

---
 models/issue_indexer.go |  3 +++
 models/issue_list.go    | 22 +++++++++++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/models/issue_indexer.go b/models/issue_indexer.go
index e43dfc9fae..c50b733492 100644
--- a/models/issue_indexer.go
+++ b/models/issue_indexer.go
@@ -49,6 +49,9 @@ func populateIssueIndexer() error {
 			if err != nil {
 				return err
 			}
+			if err = IssueList(issues).LoadComments(); err != nil {
+				return err
+			}
 			for _, issue := range issues {
 				if err := batch.Add(issue.update()); err != nil {
 					return err
diff --git a/models/issue_list.go b/models/issue_list.go
index cef4ec03c7..4910915cd0 100644
--- a/models/issue_list.go
+++ b/models/issue_list.go
@@ -290,6 +290,7 @@ func (issues IssueList) loadComments(e Engine) (err error) {
 	return nil
 }
 
+// loadAttributes loads all attributes, expect for attachments and comments
 func (issues IssueList) loadAttributes(e Engine) (err error) {
 	if _, err = issues.loadRepositories(e); err != nil {
 		return
@@ -315,18 +316,21 @@ func (issues IssueList) loadAttributes(e Engine) (err error) {
 		return
 	}
 
-	if err = issues.loadAttachments(e); err != nil {
-		return
-	}
-
-	if err = issues.loadComments(e); err != nil {
-		return
-	}
-
 	return nil
 }
 
-// LoadAttributes loads atrributes of the issues
+// LoadAttributes loads attributes of the issues, except for attachments and
+// comments
 func (issues IssueList) LoadAttributes() error {
 	return issues.loadAttributes(x)
 }
+
+// LoadAttachments loads attachments
+func (issues IssueList) LoadAttachments() error {
+	return issues.loadAttachments(x)
+}
+
+// LoadComments loads comments
+func (issues IssueList) LoadComments() error {
+	return issues.loadComments(x)
+}