(e Engine)
| 711 | type PullRequestList []*PullRequest |
| 712 | |
| 713 | func (prs PullRequestList) loadAttributes(e Engine) (err error) { |
| 714 | if len(prs) == 0 { |
| 715 | return nil |
| 716 | } |
| 717 | |
| 718 | // Load issues |
| 719 | set := make(map[int64]*Issue) |
| 720 | for i := range prs { |
| 721 | set[prs[i].IssueID] = nil |
| 722 | } |
| 723 | issueIDs := make([]int64, 0, len(prs)) |
| 724 | for issueID := range set { |
| 725 | issueIDs = append(issueIDs, issueID) |
| 726 | } |
| 727 | issues := make([]*Issue, 0, len(issueIDs)) |
| 728 | if err = e.Where("id > 0").In("id", issueIDs).Find(&issues); err != nil { |
| 729 | return errors.Newf("find issues: %v", err) |
| 730 | } |
| 731 | for i := range issues { |
| 732 | set[issues[i].ID] = issues[i] |
| 733 | } |
| 734 | for i := range prs { |
| 735 | prs[i].Issue = set[prs[i].IssueID] |
| 736 | } |
| 737 | |
| 738 | // Load attributes |
| 739 | for i := range prs { |
| 740 | if err = prs[i].loadAttributes(e); err != nil { |
| 741 | return errors.Newf("loadAttributes [%d]: %v", prs[i].ID, err) |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | return nil |
| 746 | } |
| 747 | |
| 748 | func (prs PullRequestList) LoadAttributes() error { |
| 749 | return prs.loadAttributes(x) |
no test coverage detected