Skip to content

Commit efd6506

Browse files
authored
fix: dora refdiff and change lead time logic (#4907)
1 parent 6d418ef commit efd6506

8 files changed

Lines changed: 22 additions & 12 deletions

File tree

backend/plugins/dora/tasks/change_lead_time_calculator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ limitations under the License.
1818
package tasks
1919

2020
import (
21+
"reflect"
22+
"time"
23+
2124
"github.com/apache/incubator-devlake/core/dal"
2225
"github.com/apache/incubator-devlake/core/errors"
2326
"github.com/apache/incubator-devlake/core/models/domainlayer/code"
2427
"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
2528
"github.com/apache/incubator-devlake/core/models/domainlayer/devops"
2629
"github.com/apache/incubator-devlake/core/plugin"
2730
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
28-
"reflect"
29-
"time"
3031
)
3132

3233
// CalculateChangeLeadTime calculates change lead time for a project.

backend/plugins/refdiff/e2e/raw_tables/cicd_pipeline_commits.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ github:GithubRun:1:2,commit_sha2,main,github:GithubRepo:1:484251804,""
44
github:GithubRun:1:3,commit_sha3,fix-edit-url,github:GithubRepo:1:484251804,""
55
github:GithubRun:1:4,commit_sha4,main,github:GithubRepo:1:484251804,""
66
github:GithubRun:1:5,commit_sha5,main,github:GithubRepo:1:484251804,""
7+
github:GithubRun:1:6,commit_sha6,main,github:GithubRepo:1:484251804,""
8+
github:GithubRun:1:7,commit_sha7,main,github:GithubRepo:1:484251804,""

backend/plugins/refdiff/e2e/raw_tables/cicd_pipelines.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ github:GithubRun:1:1,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251
33
github:GithubRun:1:2,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251804
44
github:GithubRun:1:3,Build workflow,SUCCESS,DONE,github:GithubRepo:1:484251804
55
github:GithubRun:1:4,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251804
6-
github:GithubRun:1:5,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251804
6+
github:GithubRun:1:5,Production workflow,FAILURE,DONE,github:GithubRepo:1:484251804
7+
github:GithubRun:1:6,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251804
8+
github:GithubRun:1:7,Production workflow,SUCCESS,DONE,github:GithubRepo:1:484251804

backend/plugins/refdiff/e2e/raw_tables/cicd_tasks.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ github:GithubJob:1:1,build-and-deploy,github:GithubRun:1:1,SUCCESS,DONE,DEPLOYME
33
github:GithubJob:1:2,build-and-deploy,github:GithubRun:1:2,SUCCESS,DONE,DEPLOYMENT,PRODUCTION,""
44
github:GithubJob:1:3,build,github:GithubRun:1:3,SUCCESS,DONE,"","",""
55
github:GithubJob:1:4,build-and-deploy,github:GithubRun:1:4,SUCCESS,DONE,DEPLOYMENT,PRODUCTION,""
6-
6+
github:GithubJob:1:5,build-and-deploy,github:GithubRun:1:5,FAILURE,DONE,DEPLOYMENT,PRODUCTION,""
7+
github:GithubJob:1:6,build-and-deploy,github:GithubRun:1:6,SUCCESS,DONE,DEPLOYMENT,STAGING,""
8+
github:GithubJob:1:7,build-and-deploy,github:GithubRun:1:7,SUCCESS,DONE,"",PRODUCTION,""

backend/plugins/refdiff/e2e/raw_tables/commit_parents.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ commit_sha2,commit_sha6
44
commit_sha3,commit_sha6
55
commit_sha4,commit_sha7
66
commit_sha5,commit_sha7
7+
commit_sha6,commit_sha7
8+
commit_sha7,commit_sha8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
project_name,table,row_id
22
project1,repos,github:GithubRepo:1:484251804
3+
project1,cicd_scopes,github:GithubRepo:1:484251804
34
project2,repos,github:GithubRepo:1:384111310
45
project3,boards,jira:JiraBoard:1:68
56

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
commit_sha,new_commit_sha,old_commit_sha,sorting_index
2-
commit_sha2,commit_sha2,commit_sha1,1
3-
commit_sha4,commit_sha4,commit_sha2,1
4-
commit_sha7,commit_sha4,commit_sha2,2
1+
new_commit_sha,old_commit_sha,commit_sha,sorting_index
2+
commit_sha2,commit_sha1,commit_sha2,1
3+
commit_sha4,commit_sha2,commit_sha4,1

backend/plugins/refdiff/tasks/project_deployment_commit_diff_calculator.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ limitations under the License.
1818
package tasks
1919

2020
import (
21+
"reflect"
22+
2123
"github.com/apache/incubator-devlake/core/dal"
2224
"github.com/apache/incubator-devlake/core/errors"
2325
"github.com/apache/incubator-devlake/core/models/domainlayer/code"
2426
"github.com/apache/incubator-devlake/core/plugin"
2527
"github.com/apache/incubator-devlake/plugins/refdiff/utils"
26-
"reflect"
2728
)
2829

2930
func CommitDiffConvertor(pipelineCommitShaList []string, existFinishedCommitDiff []code.FinishedCommitsDiff) (commitPairs []code.CommitsDiff, finishedCommitDiffs []code.FinishedCommitsDiff) {
@@ -53,8 +54,8 @@ func CalculateProjectDeploymentCommitsDiff(taskCtx plugin.SubTaskContext) errors
5354

5455
cursorScope, err := db.Cursor(
5556
dal.Select("row_id"),
56-
dal.From("project_mapping"),
57-
dal.Where("project_name = ?", projectName),
57+
dal.From("project_mapping pm"),
58+
dal.Where("pm.project_name = ? and pm.table = ?", projectName, "cicd_scopes"),
5859
)
5960
if err != nil {
6061
return err
@@ -83,7 +84,7 @@ func CalculateProjectDeploymentCommitsDiff(taskCtx plugin.SubTaskContext) errors
8384
dal.From("cicd_tasks ct"),
8485
dal.Join("left join cicd_pipelines cp on cp.id = ct.pipeline_id"),
8586
dal.Join("left join cicd_pipeline_commits cpc on cpc.pipeline_id = cp.id"),
86-
dal.Where("ct.type = ? and commit_sha != ? and repo_id=? ", "DEPLOYMENT", "", scopeId),
87+
dal.Where("ct.environment = ? and ct.type = ? and ct.result = ? and commit_sha != ? and repo_id=? ", "PRODUCTION", "DEPLOYMENT", "SUCCESS", "", scopeId),
8788
dal.Orderby("ct.started_date"),
8889
)
8990
if err != nil {

0 commit comments

Comments
 (0)