You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/08/02 01:50:14 UTC

[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2455: [feat-2433]: record execution time for plugin subtasks

klesh commented on code in PR #2455:
URL: https://github.com/apache/incubator-devlake/pull/2455#discussion_r935043588


##########
runner/run_task.go:
##########
@@ -292,3 +301,28 @@ func UpdateProgressDetail(db *gorm.DB, logger core.Logger, taskId uint64, progre
 		progressDetail.SubTaskNumber = p.SubTaskNumber
 	}
 }
+
+func runSubtask(
+	parentID uint64,
+	ctx core.SubTaskContext,
+	entryPoint core.SubTaskEntryPoint,
+) (*models.Subtask, error) {
+	beginAt := time.Now()
+	subtask := &models.Subtask{
+		Name:    ctx.GetName(),
+		TaskID:  parentID,
+		BeganAt: &beginAt,
+	}
+	defer func() {
+		finishedAt := time.Now()
+		subtask.FinishedAt = &finishedAt
+		subtask.SpentSeconds = finishedAt.Unix() - beginAt.Unix()

Review Comment:
   It is ok because each iteration took quite some time to finish, we would like the information to be saved into the database as soon as the subtask is finished, or it would be gone if any of these subtasks went south.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org