Skip to content

Commit 57b8441

Browse files
authored
Refactor smal code snippeds in models/issues/pull.go (#35301)
just code refactor nits
1 parent 4ea8f33 commit 57b8441

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

models/issues/pull.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929

3030
var ErrMustCollaborator = util.NewPermissionDeniedErrorf("user must be a collaborator")
3131

32+
const reviewedBy = "Reviewed-by: "
33+
3234
// ErrPullRequestNotExist represents a "PullRequestNotExist" kind of error.
3335
type ErrPullRequestNotExist struct {
3436
ID int64
@@ -348,7 +350,11 @@ type ReviewCount struct {
348350
func (pr *PullRequest) GetApprovalCounts(ctx context.Context) ([]*ReviewCount, error) {
349351
rCounts := make([]*ReviewCount, 0, 6)
350352
sess := db.GetEngine(ctx).Where("issue_id = ?", pr.IssueID)
351-
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)
353+
return rCounts, sess.Select("issue_id, type, count(id) as `count`").
354+
Where(builder.Eq{"official": true, "dismissed": false}).
355+
GroupBy("issue_id, type").
356+
Table("review").
357+
Find(&rCounts)
352358
}
353359

354360
// GetApprovers returns the approvers of the pull request
@@ -392,7 +398,7 @@ func (pr *PullRequest) getReviewedByLines(ctx context.Context, writer io.Writer)
392398
} else if review.Reviewer == nil {
393399
continue
394400
}
395-
if _, err := writer.Write([]byte("Reviewed-by: ")); err != nil {
401+
if _, err := writer.Write([]byte(reviewedBy)); err != nil {
396402
return err
397403
}
398404
if _, err := writer.Write([]byte(review.Reviewer.NewGitSig().String())); err != nil {

0 commit comments

Comments
 (0)