aboutsummaryrefslogtreecommitdiff
path: root/models/pull.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-09 15:45:35 -0500
committerUnknwon <u@gogs.io>2017-02-09 15:45:35 -0500
commit418dab9b969f9e933166b728e739e8c2a6846b04 (patch)
treef40efde9b3d891fda1cd86ef947bf45a294bf590 /models/pull.go
parent09ad42b918f19bb8f3f405a0521238ab66d3b702 (diff)
models/pull: load attributes when fetch list of pull requests (#4089)
Code only fetched issues corresponding to the pull requests, and left out necessary base/head repository objects, which is required later to generate API format.
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/models/pull.go b/models/pull.go
index cb52a302..7aaffe43 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -621,18 +621,18 @@ func (pr *PullRequest) AddToTaskQueue() {
type PullRequestList []*PullRequest
-func (prs PullRequestList) loadAttributes(e Engine) error {
+func (prs PullRequestList) loadAttributes(e Engine) (err error) {
if len(prs) == 0 {
return nil
}
- // Load issues.
+ // Load issues
issueIDs := make([]int64, 0, len(prs))
for i := range prs {
issueIDs = append(issueIDs, prs[i].IssueID)
}
issues := make([]*Issue, 0, len(issueIDs))
- if err := e.Where("id > 0").In("id", issueIDs).Find(&issues); err != nil {
+ if err = e.Where("id > 0").In("id", issueIDs).Find(&issues); err != nil {
return fmt.Errorf("find issues: %v", err)
}
@@ -643,6 +643,14 @@ func (prs PullRequestList) loadAttributes(e Engine) error {
for i := range prs {
prs[i].Issue = set[prs[i].IssueID]
}
+
+ // Load attributes
+ for i := range prs {
+ if err = prs[i].loadAttributes(e); err != nil {
+ return fmt.Errorf("loadAttributes [%d]: %v", prs[i].ID, err)
+ }
+ }
+
return nil
}