Skip to content

Commit 8a9c2d2

Browse files
committed
Don't load all pull requests attributes
1 parent 6a1e7d4 commit 8a9c2d2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

models/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func InsertReleases(rels ...*Release) error {
208208
return sess.Commit()
209209
}
210210

211-
// UpdateReviewsMigrationsByType updates reivews' migrations information via given git service type and original id and poster id
211+
// UpdateReviewsMigrationsByType updates reviews' migrations information via given git service type and original id and poster id
212212
func UpdateReviewsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
213213
_, err := x.Table("review").
214214
Where(builder.In("issue_id",

models/pull.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,19 @@ func GetPullRequestByID(id int64) (*PullRequest, error) {
655655
return getPullRequestByID(x, id)
656656
}
657657

658+
// GetPullRequestByIssueIDWithNoAttributes returns pull request with no attributes loaded by given issue ID.
659+
func GetPullRequestByIssueIDWithNoAttributes(issueID int64) (*PullRequest, error) {
660+
var pr PullRequest
661+
has, err := x.Where("issue_id = ?", issueID).Get(&pr)
662+
if err != nil {
663+
return nil, err
664+
}
665+
if !has {
666+
return nil, ErrPullRequestNotExist{0, issueID, 0, 0, "", ""}
667+
}
668+
return &pr, nil
669+
}
670+
658671
func getPullRequestByIssueID(e Engine, issueID int64) (*PullRequest, error) {
659672
pr := &PullRequest{
660673
IssueID: issueID,

modules/migrations/gitea.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
775775
pr, ok := g.prCache[issueID]
776776
if !ok {
777777
var err error
778-
pr, err = models.GetPullRequestByIssueID(issueID)
778+
pr, err = models.GetPullRequestByIssueIDWithNoAttributes(issueID)
779779
if err != nil {
780780
return err
781781
}

0 commit comments

Comments
 (0)