MCPcopy Index your code
hub / github.com/gogs/gogs / loadAttributes

Method loadAttributes

internal/database/pull.go:713–746  ·  view source on GitHub ↗
(e Engine)

Source from the content-addressed store, hash-verified

711type PullRequestList []*PullRequest
712
713func (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
748func (prs PullRequestList) LoadAttributes() error {
749 return prs.loadAttributes(x)

Callers 1

LoadAttributesMethod · 0.95

Calls 5

appendFunction · 0.85
InMethod · 0.80
WhereMethod · 0.80
FindMethod · 0.65
loadAttributesMethod · 0.45

Tested by

no test coverage detected