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

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


The following commit(s) were added to refs/heads/main by this push:
     new 727b516e4 fix: pending task status (#3894)
727b516e4 is described below

commit 727b516e4f9823e4fb2415f125937cac47a202a0
Author: NaRro <[email protected]>
AuthorDate: Fri Dec 9 15:21:25 2022 +0800

    fix: pending task status (#3894)
    
    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 aaca9a990..2d07801d0 100644
--- a/models/task.go
+++ b/models/task.go
@@ -34,6 +34,8 @@ const (
        TASK_CANCELLED = "TASK_CANCELLED"
 )
 
+var PendingTaskStatus = []string{TASK_CREATED, TASK_RERUN, 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 9099e5cc5..d4a017718 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, 
models.TASK_RERUN}
-               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")
                }
@@ -136,7 +135,7 @@ func GetDbPipelines(query *PipelineQuery) 
([]*models.DbPipeline, int64, errors.E
                dbQuery = dbQuery.Where("status = ?", query.Status)
        }
        if query.Pending > 0 {
-               dbQuery = dbQuery.Where("finished_at is null and status != ?", 
"TASK_FAILED")
+               dbQuery = dbQuery.Where("finished_at is null and status IN ?", 
models.PendingTaskStatus)
        }
        if query.Label != "" {
                dbQuery = dbQuery.

Reply via email to