File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,17 @@ func addBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
43
43
}
44
44
45
45
var pageSize int64 = 20
46
- totallPRs , err := x . Count ( new (models. PullRequest ) )
46
+ qresult , err := sess . QueryInterface ( "SELECT max(id) as max_id FROM pull_request" )
47
47
if err != nil {
48
48
return err
49
49
}
50
- var totalPages int64 = totallPRs / pageSize
50
+ var totalPRs int64
51
+ totalPRs , ok := qresult [0 ]["max_id" ].(int64 )
52
+ if ! ok {
53
+ // This shouldn't happen
54
+ return models.ErrNotExist {0 }
55
+ }
56
+ var totalPages int64 = totalPRs / pageSize
51
57
52
58
// Find latest review of each user in each pull request, and set official field if appropriate
53
59
reviews := []* models.Review {}
@@ -61,11 +67,13 @@ func addBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error {
61
67
62
68
for _ , review := range reviews {
63
69
if err := review .LoadAttributes (); err != nil {
64
- return err
70
+ // Error might occur if user or issue doesn't exist, ignore it.
71
+ continue
65
72
}
66
73
official , err := models .IsOfficialReviewer (review .Issue , review .Reviewer )
67
74
if err != nil {
68
- return err
75
+ // Branch might not be proteced or other error, ignore it.
76
+ continue
69
77
}
70
78
review .Official = official
71
79
You can’t perform that action at this time.
0 commit comments