diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index a1d46f8cd..f80a2284f 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -192,8 +192,10 @@ func (prs PullRequestList) LoadIssues(ctx context.Context) (IssueList, error) { return nil, nil } - // Load issues. - issueIDs := prs.GetIssueIDs() + // Load issues which are not loaded + issueIDs := container.FilterSlice(prs, func(pr *PullRequest) (int64, bool) { + return pr.IssueID, pr.Issue == nil && pr.IssueID > 0 + }) issues := make(map[int64]*Issue, len(issueIDs)) if err := db.GetEngine(ctx). In("id", issueIDs). @@ -229,10 +231,7 @@ func (prs PullRequestList) LoadIssues(ctx context.Context) (IssueList, error) { // GetIssueIDs returns all issue ids func (prs PullRequestList) GetIssueIDs() []int64 { return container.FilterSlice(prs, func(pr *PullRequest) (int64, bool) { - if pr.Issue == nil { - return pr.IssueID, pr.IssueID > 0 - } - return 0, false + return pr.IssueID, pr.IssueID > 0 }) }