You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2022/12/09 07:24:19 UTC

[incubator-devlake] branch release-v0.14 updated: fix: pending task status (#3895)

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

zhangliang2022 pushed a commit to branch release-v0.14
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.14 by this push:
     new 5e53b4501 fix: pending task status (#3895)
5e53b4501 is described below

commit 5e53b4501787fa42ab0ebbc92bef62e93de39328
Author: NaRro <co...@merico.dev>
AuthorDate: Fri Dec 9 15:24:14 2022 +0800

    fix: pending task status (#3895)
    
    fix #3893
---
 models/task.go              | 2 ++
 services/pipeline_helper.go | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/models/task.go b/models/task.go
index 090c8b662..f8a158db9 100644
--- a/models/task.go
+++ b/models/task.go
@@ -33,6 +33,8 @@ const (
 	TASK_CANCELLED = "TASK_CANCELLED"
 )
 
+var PendingTaskStatus = []string{TASK_CREATED, TASK_RUNNING}
+
 type TaskProgressDetail struct {
 	TotalSubTasks    int    `json:"totalSubTasks"`
 	FinishedSubTasks int    `json:"finishedSubTasks"`
diff --git a/services/pipeline_helper.go b/services/pipeline_helper.go
index 66cb8e5fe..365a3202b 100644
--- a/services/pipeline_helper.go
+++ b/services/pipeline_helper.go
@@ -37,8 +37,7 @@ func CreateDbPipeline(newPipeline *models.NewPipeline) (*models.DbPipeline, erro
 	defer cronLocker.Unlock()
 	if newPipeline.BlueprintId > 0 {
 		var count int64
-		status := []string{models.TASK_CREATED, models.TASK_RUNNING}
-		err := db.Model(&models.DbPipeline{}).Where("blueprint_id = ? AND status IN ?", newPipeline.BlueprintId, status).Count(&count).Error
+		err := db.Model(&models.DbPipeline{}).Where("blueprint_id = ? AND status IN ?", newPipeline.BlueprintId, models.PendingTaskStatus).Count(&count).Error
 		if err != nil {
 			return nil, errors.Default.Wrap(err, "query pipelines error")
 		}
@@ -121,7 +120,7 @@ func GetDbPipelines(query *PipelineQuery) ([]*models.DbPipeline, int64, errors.E
 		db = db.Where("status = ?", query.Status)
 	}
 	if query.Pending > 0 {
-		db = db.Where("finished_at is null and status != ?", "TASK_FAILED")
+		db = db.Where("finished_at is null and status IN ?", models.PendingTaskStatus)
 	}
 	var count int64
 	err := db.Count(&count).Error