mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Refactor smal code snippeds in models/issues/pull.go (#35301)
just code refactor nits
This commit is contained in:
		| @@ -29,6 +29,8 @@ import ( | |||||||
|  |  | ||||||
| var ErrMustCollaborator = util.NewPermissionDeniedErrorf("user must be a collaborator") | var ErrMustCollaborator = util.NewPermissionDeniedErrorf("user must be a collaborator") | ||||||
|  |  | ||||||
|  | const reviewedBy = "Reviewed-by: " | ||||||
|  |  | ||||||
| // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error. | // ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error. | ||||||
| type ErrPullRequestNotExist struct { | type ErrPullRequestNotExist struct { | ||||||
| 	ID         int64 | 	ID         int64 | ||||||
| @@ -348,7 +350,11 @@ type ReviewCount struct { | |||||||
| func (pr *PullRequest) GetApprovalCounts(ctx context.Context) ([]*ReviewCount, error) { | func (pr *PullRequest) GetApprovalCounts(ctx context.Context) ([]*ReviewCount, error) { | ||||||
| 	rCounts := make([]*ReviewCount, 0, 6) | 	rCounts := make([]*ReviewCount, 0, 6) | ||||||
| 	sess := db.GetEngine(ctx).Where("issue_id = ?", pr.IssueID) | 	sess := db.GetEngine(ctx).Where("issue_id = ?", pr.IssueID) | ||||||
| 	return rCounts, sess.Select("issue_id, type, count(id) as `count`").Where("official = ? AND dismissed = ?", true, false).GroupBy("issue_id, type").Table("review").Find(&rCounts) | 	return rCounts, sess.Select("issue_id, type, count(id) as `count`"). | ||||||
|  | 		Where(builder.Eq{"official": true, "dismissed": false}). | ||||||
|  | 		GroupBy("issue_id, type"). | ||||||
|  | 		Table("review"). | ||||||
|  | 		Find(&rCounts) | ||||||
| } | } | ||||||
|  |  | ||||||
| // GetApprovers returns the approvers of the pull request | // GetApprovers returns the approvers of the pull request | ||||||
| @@ -392,7 +398,7 @@ func (pr *PullRequest) getReviewedByLines(ctx context.Context, writer io.Writer) | |||||||
| 		} else if review.Reviewer == nil { | 		} else if review.Reviewer == nil { | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		if _, err := writer.Write([]byte("Reviewed-by: ")); err != nil { | 		if _, err := writer.Write([]byte(reviewedBy)); err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
| 		if _, err := writer.Write([]byte(review.Reviewer.NewGitSig().String())); err != nil { | 		if _, err := writer.Write([]byte(review.Reviewer.NewGitSig().String())); err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user