You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2024/04/26 07:35:25 UTC

(incubator-devlake) 02/03: fix: small fixes

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

klesh pushed a commit to branch kw-jira-issue-and-changlog-incr-mode
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 4f77e537c0985054e037a8989a6c0ca33d68a284
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Fri Apr 26 15:30:41 2024 +0800

    fix: small fixes
---
 backend/helpers/pluginhelper/api/subtask_state_manager.go | 2 +-
 backend/server/services/task.go                           | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/backend/helpers/pluginhelper/api/subtask_state_manager.go b/backend/helpers/pluginhelper/api/subtask_state_manager.go
index 27d1125f1..80d832cb7 100644
--- a/backend/helpers/pluginhelper/api/subtask_state_manager.go
+++ b/backend/helpers/pluginhelper/api/subtask_state_manager.go
@@ -124,5 +124,5 @@ func (c *SubtaskStateManager) Close() errors.Error {
 	// always update the latest success start time
 	c.state.PrevStartedAt = c.until
 	c.state.PrevConfig = c.config
-	return c.db.Update(c.state)
+	return c.db.CreateOrUpdate(c.state)
 }
diff --git a/backend/server/services/task.go b/backend/server/services/task.go
index f40757cda..fd4b8fa15 100644
--- a/backend/server/services/task.go
+++ b/backend/server/services/task.go
@@ -321,6 +321,9 @@ func GetSubTasksInfo(pipelineId uint64, shouldSanitize bool, tx dal.Dal) (*model
 	subTasksOuput.Count = totalSubtasksCount
 	completionRateFloat := float64(totalFinishedSubTasksCount) / float64(totalSubtasksCount)
 	roundedCompletionRate := math.Round(completionRateFloat*100) / 100
+	if math.IsNaN(roundedCompletionRate) {
+		roundedCompletionRate = 1
+	}
 	subTasksOuput.CompletionRate = roundedCompletionRate
 
 	subTasksOuput.Status = getTaskStatus(status)