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

(incubator-devlake) branch lw-fix-dora-0207 created (now 5204a833b)

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

lynwee pushed a change to branch lw-fix-dora-0207
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


      at 5204a833b fix(dora): add started_date when generating cicd_deployment_commits

This branch includes the following new commits:

     new 5204a833b fix(dora): add started_date when generating cicd_deployment_commits

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-devlake) 01/01: fix(dora): add started_date when generating cicd_deployment_commits

Posted by ly...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch lw-fix-dora-0207
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 5204a833b4d87dd0c3ce800ebb45f77cfc4479af
Author: Lynwee Hou <li...@merico.dev>
AuthorDate: Thu Mar 7 12:16:31 2024 +0800

    fix(dora): add started_date when generating cicd_deployment_commits
---
 backend/plugins/dora/tasks/deployment_commits_generator.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/dora/tasks/deployment_commits_generator.go b/backend/plugins/dora/tasks/deployment_commits_generator.go
index 64133ce06..a44c7dce0 100644
--- a/backend/plugins/dora/tasks/deployment_commits_generator.go
+++ b/backend/plugins/dora/tasks/deployment_commits_generator.go
@@ -47,6 +47,7 @@ type pipelineCommitEx struct {
 	OriginalResult     string
 	DurationSec        *float64
 	QueuedDurationSec  *float64
+	StartedDate        *time.Time
 	CreatedDate        *time.Time
 	FinishedDate       *time.Time
 	Environment        string
@@ -71,6 +72,7 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
 				p.status,
 				p.duration_sec,
 				p.queued_duration_sec,
+				p.started_date,
 				p.created_date,
 				p.finished_date,
 				p.environment,
@@ -161,6 +163,7 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
 				Environment:      pipelineCommit.Environment,
 				TaskDatesInfo: devops.TaskDatesInfo{
 					CreatedDate:  *pipelineCommit.CreatedDate,
+					StartedDate:  pipelineCommit.StartedDate,
 					FinishedDate: pipelineCommit.FinishedDate,
 				},
 				DurationSec:       pipelineCommit.DurationSec,
@@ -170,10 +173,13 @@ func GenerateDeploymentCommits(taskCtx plugin.SubTaskContext) errors.Error {
 				RepoId:            pipelineCommit.RepoId,
 				RepoUrl:           pipelineCommit.RepoUrl,
 			}
-			if pipelineCommit.FinishedDate != nil && pipelineCommit.DurationSec != nil {
-				s := pipelineCommit.FinishedDate.Add(-time.Duration(*pipelineCommit.DurationSec) * time.Second)
-				domainDeployCommit.StartedDate = &s
+			if domainDeployCommit.TaskDatesInfo.StartedDate == nil {
+				if pipelineCommit.FinishedDate != nil && pipelineCommit.DurationSec != nil {
+					s := pipelineCommit.FinishedDate.Add(-time.Duration(*pipelineCommit.DurationSec) * time.Second)
+					domainDeployCommit.StartedDate = &s
+				}
 			}
+
 			// it is tricky when Environment was declared on the cicd_tasks level
 			// lets talk common sense and assume that one pipeline can only be deployed to one environment
 			// so if the pipeline has both staging and production tasks, we will treat it as a production pipeline