Browse Source

Remove unnecessary IssueList attribute loads (#2936)

Ethan Koenig 1 year ago
parent
commit
0f6dc411df
2 changed files with 16 additions and 9 deletions
  1. 3 0
      models/issue_indexer.go
  2. 13 9
      models/issue_list.go

+ 3 - 0
models/issue_indexer.go

@@ -49,6 +49,9 @@ func populateIssueIndexer() error {
49 49
 			if err != nil {
50 50
 				return err
51 51
 			}
52
+			if err = IssueList(issues).LoadComments(); err != nil {
53
+				return err
54
+			}
52 55
 			for _, issue := range issues {
53 56
 				if err := batch.Add(issue.update()); err != nil {
54 57
 					return err

+ 13 - 9
models/issue_list.go

@@ -290,6 +290,7 @@ func (issues IssueList) loadComments(e Engine) (err error) {
290 290
 	return nil
291 291
 }
292 292
 
293
+// loadAttributes loads all attributes, expect for attachments and comments
293 294
 func (issues IssueList) loadAttributes(e Engine) (err error) {
294 295
 	if _, err = issues.loadRepositories(e); err != nil {
295 296
 		return
@@ -315,18 +316,21 @@ func (issues IssueList) loadAttributes(e Engine) (err error) {
315 316
 		return
316 317
 	}
317 318
 
318
-	if err = issues.loadAttachments(e); err != nil {
319
-		return
320
-	}
321
-
322
-	if err = issues.loadComments(e); err != nil {
323
-		return
324
-	}
325
-
326 319
 	return nil
327 320
 }
328 321
 
329
-// LoadAttributes loads atrributes of the issues
322
+// LoadAttributes loads attributes of the issues, except for attachments and
323
+// comments
330 324
 func (issues IssueList) LoadAttributes() error {
331 325
 	return issues.loadAttributes(x)
332 326
 }
327
+
328
+// LoadAttachments loads attachments
329
+func (issues IssueList) LoadAttachments() error {
330
+	return issues.loadAttachments(x)
331
+}
332
+
333
+// LoadComments loads comments
334
+func (issues IssueList) LoadComments() error {
335
+	return issues.loadComments(x)
336
+}