You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/09/14 07:32:46 UTC

(incubator-devlake) branch main updated: fix(framework): fix finished_record count in _devlake_subtasks (#8054)

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

abeizn 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 f0ad6f5bb fix(framework): fix finished_record count in _devlake_subtasks (#8054)
f0ad6f5bb is described below

commit f0ad6f5bbc3a1b3271c9f22456afcf91bebb39e4
Author: Lynwee <15...@qq.com>
AuthorDate: Sat Sep 14 15:32:42 2024 +0800

    fix(framework): fix finished_record count in _devlake_subtasks (#8054)
---
 backend/core/runner/run_task.go | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/backend/core/runner/run_task.go b/backend/core/runner/run_task.go
index 6abc7a760..98b913f28 100644
--- a/backend/core/runner/run_task.go
+++ b/backend/core/runner/run_task.go
@@ -370,19 +370,17 @@ func UpdateProgressDetail(basicRes context.BasicRes, taskId uint64, progressDeta
 		progressDetail.TotalRecords = p.Total
 	case plugin.SubTaskIncProgress:
 		progressDetail.FinishedRecords = p.Current
-		// 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")
-		}
 	case plugin.SetCurrentSubTask:
 		progressDetail.SubTaskName = p.SubTaskName
 		progressDetail.SubTaskNumber = p.SubTaskNumber
-	default:
-		return
+	}
+	// 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")
 	}
 }
 
@@ -418,7 +416,7 @@ func recordSubtask(basicRes context.BasicRes, subtask *models.Subtask) {
 		{ColumnName: "began_at", Value: subtask.BeganAt},
 		{ColumnName: "finished_at", Value: subtask.FinishedAt},
 		{ColumnName: "spent_seconds", Value: subtask.SpentSeconds},
-		{ColumnName: "finished_records", Value: subtask.FinishedRecords},
+		//{ColumnName: "finished_records", Value: subtask.FinishedRecords}, // FinishedRecords is zero always.
 		{ColumnName: "number", Value: subtask.Number},
 	}, where); err != nil {
 		basicRes.GetLogger().Error(err, "error writing subtask %d status to DB: %v", subtask.ID)