Skip to content

Commit ec37ffb

Browse files
committed
reformat sql to be more redable and use builder
1 parent 05d3643 commit ec37ffb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

models/issues/pull.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,11 @@ type ReviewCount struct {
350350
func (pr *PullRequest) GetApprovalCounts(ctx context.Context) ([]*ReviewCount, error) {
351351
rCounts := make([]*ReviewCount, 0, 6)
352352
sess := db.GetEngine(ctx).Where("issue_id = ?", pr.IssueID)
353-
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)
354358
}
355359

356360
// GetApprovers returns the approvers of the pull request

0 commit comments

Comments
 (0)