This is an automated email from the ASF dual-hosted git repository.
klesh 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 39e9751ff refactor: use finished_date to calculate change lead time
(#5026)
39e9751ff is described below
commit 39e9751ff3e33beb57bfc18805b73cc1acd724fa
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Apr 25 14:15:58 2023 +0800
refactor: use finished_date to calculate change lead time (#5026)
---
.../change_lead_time/cicd_deployment_commits.csv | 34 +++++++++++-----------
.../dora/tasks/change_lead_time_calculator.go | 5 ++--
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git
a/backend/plugins/dora/e2e/change_lead_time/cicd_deployment_commits.csv
b/backend/plugins/dora/e2e/change_lead_time/cicd_deployment_commits.csv
index 4252accd6..9f2040747 100644
--- a/backend/plugins/dora/e2e/change_lead_time/cicd_deployment_commits.csv
+++ b/backend/plugins/dora/e2e/change_lead_time/cicd_deployment_commits.csv
@@ -1,17 +1,17 @@
-id,result,started_date,duration_sec,cicd_pipeline_id,cicd_scope_id,repo_url,environment,prev_success_deployment_commit_id,_raw_data_remark,commit_sha,created_date
-1,SUCCESS,2023-04-10T06:51:47.000+00:00,60,pipeline1,cicd1,REPO111,PRODUCTION,,project1,commit1,2023-4-10
6:51:47
-2,SUCCESS,2023-04-10T06:53:51.000+00:00,60,pipeline1,cicd1,REPO222,PRODUCTION,,project1,commit2,2023-4-10
6:53:51
-3,SUCCESS,2023-04-13T07:21:16.000+00:00,60,pipeline2,cicd2,REPO111,PRODUCTION,,,commit3,2023-4-13
7:21:16
-4,SUCCESS,2023-04-13T07:22:14.000+00:00,60,pipeline2,cicd2,REPO333,PRODUCTION,,,commit4,2023-4-13
7:22:14
-5,SUCCESS,2023-04-13T07:28:14.000+00:00,60,pipeline4,cicd1,REPO111,PRODUCTION,1,project1,commit5,2023-4-13
7:28:14
-6,SUCCESS,2023-04-13T07:29:34.000+00:00,60,pipeline4,cicd1,REPO222,PRODUCTION,2,project1,commit6,2023-4-13
7:29:34
-7,SUCCESS,2023-04-13T07:31:53.000+00:00,60,pipeline5,cicd1,REPO111,STAGING,,,commit7,2023-4-13
7:31:53
-8,SUCCESS,2023-04-13T07:36:30.000+00:00,60,pipeline5,cicd1,REPO111,STAGING,7,,commit8,2023-4-13
7:36:30
-9,SUCCESS,2023-04-13T07:51:26.000+00:00,60,pipeline6,cicd1,REPO111,PRODUCTION,5,project1,commit9,2023-4-13
7:51:26
-10,SUCCESS,2023-04-13T07:53:31.000+00:00,60,pipeline6,cicd1,REPO222,PRODUCTION,6,project1,commit10,2023-4-13
7:53:31
-11,FAILURE,2023-04-13T07:54:39.000+00:00,60,pipeline7,cicd2,REPO111,PRODUCTION,,,commit11,2023-4-13
7:54:39
-12,SUCCESS,2023-04-13T07:55:01.000+00:00,60,pipeline7,cicd2,REPO333,PRODUCTION,4,,commit12,2023-4-13
7:55:01
-13,SUCCESS,2023-04-13T07:56:39.000+00:00,60,pipeline7,cicd2,REPO111,PRODUCTION,3,,commit13,2023-4-13
7:56:39
-14,FAILURE,2023-04-13T07:57:26.000+00:00,60,pipeline8,cicd3,REPO111,PRODUCTION,,,commit14,2023-4-13
7:57:26
-15,SUCCESS,2023-04-13T07:57:45.000+00:00,60,pipeline9,cicd3,REPO111,PRODUCTION,,,commit15,2023-4-13
7:57:45
-16,SUCCESS,2023-04-13T07:58:24.000+00:00,60,pipeline10,cicd3,REPO333,,,,commit16,2023-4-13
7:58:24
\ No newline at end of file
+id,result,started_date,duration_sec,cicd_pipeline_id,cicd_scope_id,repo_url,environment,prev_success_deployment_commit_id,_raw_data_remark,commit_sha,created_date,finished_date
+1,SUCCESS,2023-04-10T06:51:47.000+00:00,60,pipeline1,cicd1,REPO111,PRODUCTION,,project1,commit1,2023-4-10
6:51:47,2023-04-10T06:52:47.000+00:00
+2,SUCCESS,2023-04-10T06:53:51.000+00:00,60,pipeline1,cicd1,REPO222,PRODUCTION,,project1,commit2,2023-4-10
6:53:51,2023-04-10T06:54:51.000+00:00
+3,SUCCESS,2023-04-13T07:21:16.000+00:00,60,pipeline2,cicd2,REPO111,PRODUCTION,,,commit3,2023-4-13
7:21:16,2023-04-13T07:22:16.000+00:00
+4,SUCCESS,2023-04-13T07:22:14.000+00:00,60,pipeline2,cicd2,REPO333,PRODUCTION,,,commit4,2023-4-13
7:22:14,2023-04-13T07:23:14.000+00:00
+5,SUCCESS,2023-04-13T07:28:14.000+00:00,60,pipeline4,cicd1,REPO111,PRODUCTION,1,project1,commit5,2023-4-13
7:28:14,2023-04-13T07:29:14.000+00:00
+6,SUCCESS,2023-04-13T07:29:34.000+00:00,60,pipeline4,cicd1,REPO222,PRODUCTION,2,project1,commit6,2023-4-13
7:29:34,2023-04-13T07:30:34.000+00:00
+7,SUCCESS,2023-04-13T07:31:53.000+00:00,60,pipeline5,cicd1,REPO111,STAGING,,,commit7,2023-4-13
7:31:53,2023-04-13T07:32:53.000+00:00
+8,SUCCESS,2023-04-13T07:36:30.000+00:00,60,pipeline5,cicd1,REPO111,STAGING,7,,commit8,2023-4-13
7:36:30,2023-04-13T07:37:30.000+00:00
+9,SUCCESS,2023-04-13T07:51:26.000+00:00,60,pipeline6,cicd1,REPO111,PRODUCTION,5,project1,commit9,2023-4-13
7:51:26,2023-04-13T07:52:26.000+00:00
+10,SUCCESS,2023-04-13T07:53:31.000+00:00,60,pipeline6,cicd1,REPO222,PRODUCTION,6,project1,commit10,2023-4-13
7:53:31,2023-04-13T07:54:31.000+00:00
+11,FAILURE,2023-04-13T07:54:39.000+00:00,60,pipeline7,cicd2,REPO111,PRODUCTION,,,commit11,2023-4-13
7:54:39,2023-04-13T07:55:39.000+00:00
+12,SUCCESS,2023-04-13T07:55:01.000+00:00,60,pipeline7,cicd2,REPO333,PRODUCTION,4,,commit12,2023-4-13
7:55:01,2023-04-13T07:56:01.000+00:00
+13,SUCCESS,2023-04-13T07:56:39.000+00:00,60,pipeline7,cicd2,REPO111,PRODUCTION,3,,commit13,2023-4-13
7:56:39,2023-04-13T07:57:39.000+00:00
+14,FAILURE,2023-04-13T07:57:26.000+00:00,60,pipeline8,cicd3,REPO111,PRODUCTION,,,commit14,2023-4-13
7:57:26,2023-04-13T07:58:26.000+00:00
+15,SUCCESS,2023-04-13T07:57:45.000+00:00,60,pipeline9,cicd3,REPO111,PRODUCTION,,,commit15,2023-4-13
7:57:45,2023-04-13T07:58:45.000+00:00
+16,SUCCESS,2023-04-13T07:58:24.000+00:00,60,pipeline10,cicd3,REPO333,,,,commit16,2023-4-13
7:58:24,2023-04-13T07:59:24.000+00:00
\ No newline at end of file
diff --git a/backend/plugins/dora/tasks/change_lead_time_calculator.go
b/backend/plugins/dora/tasks/change_lead_time_calculator.go
index d2803de64..93879e390 100644
--- a/backend/plugins/dora/tasks/change_lead_time_calculator.go
+++ b/backend/plugins/dora/tasks/change_lead_time_calculator.go
@@ -109,9 +109,8 @@ func CalculateChangeLeadTime(taskCtx plugin.SubTaskContext)
errors.Error {
}
// Calculate PR deploy time
- if deployment != nil && deployment.StartedDate != nil {
- deploymentFinishedDate :=
deployment.StartedDate.Add(time.Duration(*deployment.DurationSec) * time.Second)
- projectPrMetric.PrDeployTime =
computeTimeSpan(pr.MergedDate, &deploymentFinishedDate)
+ if deployment != nil && deployment.FinishedDate != nil {
+ projectPrMetric.PrDeployTime =
computeTimeSpan(pr.MergedDate, deployment.FinishedDate)
projectPrMetric.DeploymentCommitId =
deployment.Id
} else {
logger.Debug("deploy time of pr %v is nil\n",
pr.PullRequestKey)