@@ -1058,29 +1058,30 @@ func (pr *PullRequest) checkAndUpdateStatus() {
1058
1058
// TODO: test more pull requests at same time.
1059
1059
func TestPullRequests () {
1060
1060
prs := make ([]* PullRequest , 0 , 10 )
1061
- x .Iterate (PullRequest {
1062
- Status : PullRequestStatusChecking ,
1063
- },
1064
- func (idx int , bean interface {}) error {
1065
- pr := bean .(* PullRequest )
1066
-
1067
- if err := pr .GetBaseRepo (); err != nil {
1068
- log .Error (3 , "GetBaseRepo: %v" , err )
1069
- return nil
1070
- }
1071
- if pr .manuallyMerged () {
1072
- return nil
1073
- }
1074
- if err := pr .testPatch (); err != nil {
1075
- log .Error (3 , "testPatch: %v" , err )
1076
- return nil
1077
- }
1078
- prs = append (prs , pr )
1079
- return nil
1080
- })
1061
+
1062
+ err := x .Where ("status = ?" , PullRequestStatusChecking ).Find (& prs )
1063
+ if err != nil {
1064
+ log .Error (3 , "Find Checking PRs" , err )
1065
+ return
1066
+ }
1067
+
1068
+ var checkedPRs = make (map [int64 ]struct {})
1081
1069
1082
1070
// Update pull request status.
1083
1071
for _ , pr := range prs {
1072
+ checkedPRs [pr .ID ] = struct {}{}
1073
+ if err := pr .GetBaseRepo (); err != nil {
1074
+ log .Error (3 , "GetBaseRepo: %v" , err )
1075
+ continue
1076
+ }
1077
+ if pr .manuallyMerged () {
1078
+ continue
1079
+ }
1080
+ if err := pr .testPatch (); err != nil {
1081
+ log .Error (3 , "testPatch: %v" , err )
1082
+ continue
1083
+ }
1084
+
1084
1085
pr .checkAndUpdateStatus ()
1085
1086
}
1086
1087
@@ -1089,7 +1090,12 @@ func TestPullRequests() {
1089
1090
log .Trace ("TestPullRequests[%v]: processing test task" , prID )
1090
1091
pullRequestQueue .Remove (prID )
1091
1092
1092
- pr , err := GetPullRequestByID (com .StrTo (prID ).MustInt64 ())
1093
+ id := com .StrTo (prID ).MustInt64 ()
1094
+ if _ , ok := checkedPRs [id ]; ok {
1095
+ continue
1096
+ }
1097
+
1098
+ pr , err := GetPullRequestByID (id )
1093
1099
if err != nil {
1094
1100
log .Error (4 , "GetPullRequestByID[%s]: %v" , prID , err )
1095
1101
continue
0 commit comments