You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2022/10/20 01:30:17 UTC

[incubator-devlake] 06/06: fix: skip when enrichGithubPrComment not found PR

This is an automated email from the ASF dual-hosted git repository.

likyh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit db184634add9e63b5ddade86b7937c910b4fef0e
Author: linyh <ya...@meri.co>
AuthorDate: Wed Oct 19 20:54:33 2022 +0800

    fix: skip when enrichGithubPrComment not found PR
---
 plugins/github/tasks/pr_review_comment_extractor.go | 21 ++++++++++++---------
 services/pipeline.go                                |  4 ++--
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/plugins/github/tasks/pr_review_comment_extractor.go b/plugins/github/tasks/pr_review_comment_extractor.go
index fae44a83..0307f720 100644
--- a/plugins/github/tasks/pr_review_comment_extractor.go
+++ b/plugins/github/tasks/pr_review_comment_extractor.go
@@ -19,14 +19,15 @@ package tasks
 
 import (
 	"encoding/json"
+	goerror "errors"
 	"fmt"
-	"github.com/apache/incubator-devlake/errors"
-	"github.com/apache/incubator-devlake/plugins/core/dal"
 	"gorm.io/gorm"
 	"regexp"
 	"strconv"
 
+	"github.com/apache/incubator-devlake/errors"
 	"github.com/apache/incubator-devlake/plugins/core"
+	"github.com/apache/incubator-devlake/plugins/core/dal"
 	"github.com/apache/incubator-devlake/plugins/github/models"
 	"github.com/apache/incubator-devlake/plugins/helper"
 )
@@ -99,11 +100,11 @@ func ExtractApiPrReviewComments(taskCtx core.SubTaskContext) errors.Error {
 				githubPrComment.AuthorUserId = prReviewComment.User.Id
 				githubPrComment.AuthorUsername = prReviewComment.User.Login
 
-			githubAccount, err := convertAccount(prReviewComment.User, data.Repo.GithubId, data.Options.ConnectionId)
-			if err != nil {
-				return nil, err
-			}
-			results = append(results, githubAccount)
+				githubAccount, err := convertAccount(prReviewComment.User, data.Repo.GithubId, data.Options.ConnectionId)
+				if err != nil {
+					return nil, err
+				}
+				results = append(results, githubAccount)
 			}
 
 			results = append(results, githubPrComment)
@@ -127,8 +128,10 @@ func enrichGithubPrComment(data *GithubTaskData, db dal.Dal, prUrlRegex *regexp.
 		}
 		pr := &models.GithubPullRequest{}
 		err = db.First(pr, dal.Where("connection_id = ? and number = ? and repo_id = ?", data.Options.ConnectionId, prNumber, data.Repo.GithubId))
-		if err != nil && err != gorm.ErrRecordNotFound {
-			return 0, errors.NotFound.Wrap(err, "github pull request not found in DB")
+		if goerror.Is(err, gorm.ErrRecordNotFound) {
+			return 0, nil
+		} else if err != nil {
+			return 0, errors.NotFound.Wrap(err, "github pull request parse failed ")
 		}
 		return pr.GithubId, nil
 	}
diff --git a/services/pipeline.go b/services/pipeline.go
index 47e945eb..01edd9a6 100644
--- a/services/pipeline.go
+++ b/services/pipeline.go
@@ -157,14 +157,14 @@ func RunPipelineInQueue(pipelineMaxParallel int64) {
 	sema := semaphore.NewWeighted(pipelineMaxParallel)
 	startedPipelineIds := []uint64{}
 	for {
-		globalPipelineLog.Info("wait for new pipeline")
+		globalPipelineLog.Info("acquire lock")
 		// start goroutine when sema lock ready and pipeline exist.
 		// to avoid read old pipeline, acquire lock before read exist pipeline
 		err := sema.Acquire(context.TODO(), 1)
 		if err != nil {
 			panic(err)
 		}
-		globalPipelineLog.Info("get lock and wait pipeline")
+		globalPipelineLog.Info("get lock and wait next pipeline")
 		dbPipeline := &models.DbPipeline{}
 		for {
 			cronLocker.Lock()