MCPcopy Create free account
hub / github.com/gogs/gogs / loadAttributes

Method loadAttributes

internal/database/issue.go:94–158  ·  view source on GitHub ↗
(e Engine)

Source from the content-addressed store, hash-verified

92}
93
94func (issue *Issue) loadAttributes(e Engine) (err error) {
95 if issue.Repo == nil {
96 issue.Repo, err = getRepositoryByID(e, issue.RepoID)
97 if err != nil {
98 return errors.Newf("getRepositoryByID [%d]: %v", issue.RepoID, err)
99 }
100 }
101
102 if issue.Poster == nil {
103 issue.Poster, err = getUserByID(e, issue.PosterID)
104 if err != nil {
105 if IsErrUserNotExist(err) {
106 issue.PosterID = -1
107 issue.Poster = NewGhostUser()
108 } else {
109 return errors.Newf("getUserByID.(Poster) [%d]: %v", issue.PosterID, err)
110 }
111 }
112 }
113
114 if issue.Labels == nil {
115 issue.Labels, err = getLabelsByIssueID(e, issue.ID)
116 if err != nil {
117 return errors.Newf("getLabelsByIssueID [%d]: %v", issue.ID, err)
118 }
119 }
120
121 if issue.Milestone == nil && issue.MilestoneID > 0 {
122 issue.Milestone, err = getMilestoneByRepoID(e, issue.RepoID, issue.MilestoneID)
123 if err != nil {
124 return errors.Newf("getMilestoneByRepoID [repo_id: %d, milestone_id: %d]: %v", issue.RepoID, issue.MilestoneID, err)
125 }
126 }
127
128 if issue.Assignee == nil && issue.AssigneeID > 0 {
129 issue.Assignee, err = getUserByID(e, issue.AssigneeID)
130 if err != nil {
131 return errors.Newf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err)
132 }
133 }
134
135 if issue.IsPull && issue.PullRequest == nil {
136 // It is possible pull request is not yet created.
137 issue.PullRequest, err = getPullRequestByIssueID(e, issue.ID)
138 if err != nil && !IsErrPullRequestNotExist(err) {
139 return errors.Newf("getPullRequestByIssueID [%d]: %v", issue.ID, err)
140 }
141 }
142
143 if issue.Attachments == nil {
144 issue.Attachments, err = getAttachmentsByIssueID(e, issue.ID)
145 if err != nil {
146 return errors.Newf("getAttachmentsByIssueID [%d]: %v", issue.ID, err)
147 }
148 }
149
150 if issue.Comments == nil {
151 issue.Comments, err = getCommentsByIssueID(e, issue.ID)

Callers 3

LoadAttributesMethod · 0.95
newIssueFunction · 0.45
getIssueByIDFunction · 0.45

Implementers 1

mailerIssueinternal/database/issue_mail.go

Calls 10

getRepositoryByIDFunction · 0.85
getUserByIDFunction · 0.85
IsErrUserNotExistFunction · 0.85
NewGhostUserFunction · 0.85
getLabelsByIssueIDFunction · 0.85
getMilestoneByRepoIDFunction · 0.85
getPullRequestByIssueIDFunction · 0.85
IsErrPullRequestNotExistFunction · 0.85
getAttachmentsByIssueIDFunction · 0.85
getCommentsByIssueIDFunction · 0.85

Tested by

no test coverage detected