diff --git a/backend/core/runner/run_task.go b/backend/core/runner/run_task.go index 98b913f284b..574c0e1e946 100644 --- a/backend/core/runner/run_task.go +++ b/backend/core/runner/run_task.go @@ -20,10 +20,11 @@ package runner import ( gocontext "context" "fmt" - "github.com/apache/incubator-devlake/core/models/common" "strings" "time" + "github.com/apache/incubator-devlake/core/models/common" + "github.com/apache/incubator-devlake/core/context" "github.com/apache/incubator-devlake/core/dal" "github.com/apache/incubator-devlake/core/errors" @@ -354,6 +355,7 @@ func UpdateProgressDetail(basicRes context.BasicRes, taskId uint64, progressDeta Model: common.Model{ID: taskId}, } subtask := &models.Subtask{} + originalFinishedRecords := progressDetail.FinishedRecords switch p.Type { case plugin.TaskSetProgress: progressDetail.TotalSubTasks = p.Total @@ -374,13 +376,18 @@ func UpdateProgressDetail(basicRes context.BasicRes, taskId uint64, progressDeta progressDetail.SubTaskName = p.SubTaskName progressDetail.SubTaskNumber = p.SubTaskNumber } - // update subtask progress - where := dal.Where("task_id = ? and name = ?", taskId, progressDetail.SubTaskName) - err := basicRes.GetDal().UpdateColumns(subtask, []dal.DalSet{ - {ColumnName: "finished_records", Value: progressDetail.FinishedRecords}, - }, where) - if err != nil { - basicRes.GetLogger().Error(err, "failed to update _devlake_subtasks progress") + currentFinishedRecords := progressDetail.FinishedRecords + currentTotalRecords := progressDetail.TotalRecords + // do not update progress if progress less than 1% + if currentTotalRecords > 0 && float64(currentFinishedRecords-originalFinishedRecords)/float64(currentTotalRecords) > 0.01 { + // update subtask progress + where := dal.Where("task_id = ? and name = ?", taskId, progressDetail.SubTaskName) + err := basicRes.GetDal().UpdateColumns(subtask, []dal.DalSet{ + {ColumnName: "finished_records", Value: progressDetail.FinishedRecords}, + }, where) + if err != nil { + basicRes.GetLogger().Error(err, "failed to update _devlake_subtasks progress") + } } }