You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by he...@apache.org on 2023/04/11 03:12:53 UTC

[incubator-devlake] branch main updated: fix(dora): ignore to calculate cycletime if pr has not been deployed (#4858)

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

hez 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 e35bb73c7 fix(dora): ignore to calculate cycletime if pr has not been deployed (#4858)
e35bb73c7 is described below

commit e35bb73c79e78fe146cc9dbf9c71a7f36de453cb
Author: Warren Chen <yi...@merico.dev>
AuthorDate: Tue Apr 11 11:12:47 2023 +0800

    fix(dora): ignore to calculate cycletime if pr has not been deployed (#4858)
    
    * fix(dora): ignore to calculate cycletime if pr has not been deployed
    
    * fix(dora): retaining the cumulative logic of the previous cycle time
    
    * fix(dora): fix for review
---
 backend/plugins/dora/e2e/snapshot_tables/project_pr_metrics.csv | 4 ++--
 backend/plugins/dora/tasks/change_lead_time_calculator.go       | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/backend/plugins/dora/e2e/snapshot_tables/project_pr_metrics.csv b/backend/plugins/dora/e2e/snapshot_tables/project_pr_metrics.csv
index eb02a5df1..2782878c7 100644
--- a/backend/plugins/dora/e2e/snapshot_tables/project_pr_metrics.csv
+++ b/backend/plugins/dora/e2e/snapshot_tables/project_pr_metrics.csv
@@ -3,5 +3,5 @@ github:GithubPullRequest:1:1043463302,project1,75ab753225b5b8acf3bc6e40e463b54b6
 github:GithubPullRequest:1:1048233599,project1,4f8cdefc9a9d53af16dd482c61623312eb9e9b5e,,github:GithubPrComment:1:1239007576,194,4033,task12,76605,80833
 github:GithubPullRequest:1:1049191985,project1,4b71faf666833c0c7b915a512811e2c5e746d3de,1,github:GithubPrComment:1:965369774,156,1712,task13,115026,116896
 github:GithubPullRequest:1:1051112182,project1,,,,,,task14,98341,98398
-github:GithubPullRequest:1:1051574863,project1,,,,,,,,108
-github:GithubPullRequest:1:1051637383,project1,9d53fb594958e65456793caa1bfa8d07a7614291,1,github:GithubPrReview:1:1102479199,45,13,,,60
+github:GithubPullRequest:1:1051574863,project1,,,,,,,,
+github:GithubPullRequest:1:1051637383,project1,9d53fb594958e65456793caa1bfa8d07a7614291,1,github:GithubPrReview:1:1102479199,45,13,,,
diff --git a/backend/plugins/dora/tasks/change_lead_time_calculator.go b/backend/plugins/dora/tasks/change_lead_time_calculator.go
index c28b22d14..c5743e670 100644
--- a/backend/plugins/dora/tasks/change_lead_time_calculator.go
+++ b/backend/plugins/dora/tasks/change_lead_time_calculator.go
@@ -123,7 +123,10 @@ func CalculateChangeLeadTime(taskCtx plugin.SubTaskContext) errors.Error {
 			}
 
 			// Calculate PR cycle time
-			projectPrMetric.PrCycleTime = nil
+			if deployment == nil || projectPrMetric.PrDeployTime == nil {
+				// Return the projectPrMetric with nill cycle time
+				return []interface{}{projectPrMetric}, nil
+			}
 			var result int64
 			if projectPrMetric.PrCodingTime != nil {
 				result += *projectPrMetric.PrCodingTime
@@ -131,9 +134,7 @@ func CalculateChangeLeadTime(taskCtx plugin.SubTaskContext) errors.Error {
 			if prDuring != nil {
 				result += *prDuring
 			}
-			if projectPrMetric.PrDeployTime != nil {
-				result += *projectPrMetric.PrDeployTime
-			}
+			result += *projectPrMetric.PrDeployTime
 			if result > 0 {
 				projectPrMetric.PrCycleTime = &result
 			}