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.
pull/3954/merge
Unknwon 2017-02-09 15:45:35 -05:00
parent 09ad42b918
commit 418dab9b96
No known key found for this signature in database
GPG Key ID: FB9F411CDD69BEC1
3 changed files with 13 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.136.0209"
const APP_VER = "0.9.137.0209"
func init() {
setting.AppVer = APP_VER

View File

@ -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
}

View File

@ -1 +1 @@
0.9.136.0209
0.9.137.0209