Skip to content

Commit

Permalink
refactor: use finished_date to calculate change lead time (#5026)
Browse files Browse the repository at this point in the history
  • Loading branch information
mindlesscloud authored Apr 25, 2023
1 parent 5d81ae6 commit 39e9751
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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
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
5 changes: 2 additions & 3 deletions backend/plugins/dora/tasks/change_lead_time_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 39e9751

Please sign in to comment.