You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by li...@apache.org on 2022/11/21 07:58:04 UTC

[incubator-devlake] branch main updated: Feat connect incident to deployment (#3768)

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

likyh 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 00b38d35d Feat connect incident to deployment (#3768)
00b38d35d is described below

commit 00b38d35d391ab781c0a5008884cdf7982b2d432
Author: Warren Chen <yi...@merico.dev>
AuthorDate: Mon Nov 21 15:58:00 2022 +0800

    Feat connect incident to deployment (#3768)
    
    * feat(dora): update logic for change lead time
    
    closes #3516
    
    * feat(dora): update e2e according to review
    
    * feat(dora): connect incident to deployment
    
    * fix(zentao): use const instead of string
---
 .../crossdomain/project_issue_metric.go            | 32 +++++++++++++++
 .../20221120_add_project_issue_meric.go            | 47 ++++++++++++++++++++++
 .../archived/project_issue_metric.go               | 28 +++++++++++++
 models/migrationscripts/register.go                |  1 +
 ..._test.go => connect_incident_to_deploy_test.go} | 22 +++++-----
 plugins/dora/e2e/raw_tables/board_issues.csv       | 24 +++++------
 plugins/dora/e2e/raw_tables/board_repos.csv        |  2 -
 plugins/dora/e2e/raw_tables/issues.csv             | 30 +++++++-------
 .../raw_tables/lake_cicd_tasks_for_other_jobs.csv  | 22 ----------
 plugins/dora/e2e/raw_tables/project_mapping.csv    |  3 ++
 .../e2e/snapshot_tables/project_issue_metrics.csv  |  5 +++
 plugins/dora/impl/impl.go                          |  2 +-
 plugins/dora/tasks/change_lead_time_calculator.go  |  3 +-
 ...y_connector.go => incident_deploy_connector.go} | 47 ++++++++++++++--------
 14 files changed, 186 insertions(+), 82 deletions(-)

diff --git a/models/domainlayer/crossdomain/project_issue_metric.go b/models/domainlayer/crossdomain/project_issue_metric.go
new file mode 100644
index 000000000..15a919b56
--- /dev/null
+++ b/models/domainlayer/crossdomain/project_issue_metric.go
@@ -0,0 +1,32 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package crossdomain
+
+import (
+	"github.com/apache/incubator-devlake/models/domainlayer"
+)
+
+type ProjectIssueMetric struct {
+	domainlayer.DomainEntity
+	ProjectName  string `gorm:"primaryKey;type:varchar(100)"`
+	DeploymentId string
+}
+
+func (ProjectIssueMetric) TableName() string {
+	return "project_issue_metrics"
+}
diff --git a/models/migrationscripts/20221120_add_project_issue_meric.go b/models/migrationscripts/20221120_add_project_issue_meric.go
new file mode 100644
index 000000000..3cdab7f70
--- /dev/null
+++ b/models/migrationscripts/20221120_add_project_issue_meric.go
@@ -0,0 +1,47 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"github.com/apache/incubator-devlake/errors"
+	"github.com/apache/incubator-devlake/helpers/migrationhelper"
+	"github.com/apache/incubator-devlake/models/migrationscripts/archived"
+	"github.com/apache/incubator-devlake/plugins/core"
+)
+
+type addProjectIssueMetric struct{}
+
+func (u *addProjectIssueMetric) Up(baseRes core.BasicRes) errors.Error {
+	db := baseRes.GetDal()
+	err := migrationhelper.AutoMigrateTables(
+		baseRes,
+		&archived.ProjectIssueMetric{},
+	)
+	if err != nil {
+		return err
+	}
+	return db.DropColumns(`issues`, "deployment_id")
+}
+
+func (*addProjectIssueMetric) Version() uint64 {
+	return 20221120000001
+}
+
+func (*addProjectIssueMetric) Name() string {
+	return "add project issue metric tables"
+}
diff --git a/models/migrationscripts/archived/project_issue_metric.go b/models/migrationscripts/archived/project_issue_metric.go
new file mode 100644
index 000000000..1fc49f8ac
--- /dev/null
+++ b/models/migrationscripts/archived/project_issue_metric.go
@@ -0,0 +1,28 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package archived
+
+type ProjectIssueMetric struct {
+	DomainEntity
+	ProjectName  string `gorm:"primaryKey;type:varchar(100)"`
+	DeploymentId string
+}
+
+func (ProjectIssueMetric) TableName() string {
+	return "project_issue_metrics"
+}
diff --git a/models/migrationscripts/register.go b/models/migrationscripts/register.go
index e28c33174..00478e238 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -59,5 +59,6 @@ func All() []core.MigrationScript {
 		new(addProjectPrMetric),
 		new(addProjectTables),
 		new(addProjectToBluePrint),
+		new(addProjectIssueMetric),
 	}
 }
diff --git a/plugins/dora/e2e/connect_issue_deploy_test.go b/plugins/dora/e2e/connect_incident_to_deploy_test.go
similarity index 69%
rename from plugins/dora/e2e/connect_issue_deploy_test.go
rename to plugins/dora/e2e/connect_incident_to_deploy_test.go
index 339f849db..4e508f5e8 100644
--- a/plugins/dora/e2e/connect_issue_deploy_test.go
+++ b/plugins/dora/e2e/connect_incident_to_deploy_test.go
@@ -18,44 +18,40 @@ limitations under the License.
 package e2e
 
 import (
+	"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
 	"testing"
 
 	"github.com/apache/incubator-devlake/helpers/e2ehelper"
 	"github.com/apache/incubator-devlake/models/common"
-	"github.com/apache/incubator-devlake/models/domainlayer/code"
-	"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
 	"github.com/apache/incubator-devlake/models/domainlayer/devops"
 	"github.com/apache/incubator-devlake/models/domainlayer/ticket"
 	"github.com/apache/incubator-devlake/plugins/dora/impl"
 	"github.com/apache/incubator-devlake/plugins/dora/tasks"
 )
 
-func TestConnectIssueDeployDataFlow(t *testing.T) {
+func TestConnectIncidentToDeploymentDataFlow(t *testing.T) {
 	var plugin impl.Dora
 	dataflowTester := e2ehelper.NewDataFlowTester(t, "dora", plugin)
 
 	taskData := &tasks.DoraTaskData{
 		Options: &tasks.DoraOptions{
-			RepoId: "github:GithubRepo:1:384111310",
+			ProjectName: "project1",
 			TransformationRules: tasks.TransformationRules{
 				ProductionPattern: "(?i)deploy",
-				StagingPattern:    "(?i)stag",
-				TestingPattern:    "(?i)test",
 			},
 		},
 	}
-	dataflowTester.FlushTabler(&code.PullRequest{})
 	// import raw data table
-	dataflowTester.ImportCsvIntoTabler("./raw_tables/lake_cicd_pipeline_commits.csv", &devops.CiCDPipelineCommit{})
-	dataflowTester.ImportCsvIntoTabler("./raw_tables/lake_cicd_tasks_for_other_jobs.csv", &devops.CICDTask{})
+	dataflowTester.ImportCsvIntoTabler("./raw_tables/cicd_tasks_changeleadtime.csv", &devops.CICDTask{})
+	dataflowTester.ImportCsvIntoTabler("./raw_tables/project_mapping.csv", &crossdomain.ProjectMapping{})
 	dataflowTester.ImportCsvIntoTabler("./raw_tables/board_issues.csv", &ticket.BoardIssue{})
-	dataflowTester.ImportCsvIntoTabler("./raw_tables/board_repos.csv", &crossdomain.BoardRepo{})
 	dataflowTester.ImportCsvIntoTabler("./raw_tables/issues.csv", &ticket.Issue{})
 
 	// verify converter
-	dataflowTester.Subtask(tasks.ConnectIssueDeployMeta, taskData)
-	dataflowTester.VerifyTableWithOptions(&ticket.Issue{}, e2ehelper.TableOptions{
-		CSVRelPath:  "./snapshot_tables/issues.csv",
+	dataflowTester.FlushTabler(&crossdomain.ProjectIssueMetric{})
+	dataflowTester.Subtask(tasks.ConnectIncidentToDeploymentMeta, taskData)
+	dataflowTester.VerifyTableWithOptions(&crossdomain.ProjectIssueMetric{}, e2ehelper.TableOptions{
+		CSVRelPath:  "./snapshot_tables/project_issue_metrics.csv",
 		IgnoreTypes: []interface{}{common.NoPKModel{}},
 	})
 }
diff --git a/plugins/dora/e2e/raw_tables/board_issues.csv b/plugins/dora/e2e/raw_tables/board_issues.csv
index 7a5d40b12..9529b157d 100644
--- a/plugins/dora/e2e/raw_tables/board_issues.csv
+++ b/plugins/dora/e2e/raw_tables/board_issues.csv
@@ -1,12 +1,12 @@
-board_id,issue_id,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-github:GithubRepo:1:384111310,github:GithubIssue:1:1367714738,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3370,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1370813347,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3388,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1370816458,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3389,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1370833897,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3390,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1371315795,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3392,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1371320153,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3393,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1371541422,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3394,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1371617668,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3395,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1372381019,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3397,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1372550825,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3399,""
-github:GithubRepo:1:384111310,github:GithubIssue:1:1372581663,2022-09-15 05:36:36.083,2022-09-15 05:36:36.083,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3401,""
+board_id,issue_id
+board1,github:GithubIssue:1:1367714738
+board1,github:GithubIssue:1:1370813347
+board1,github:GithubIssue:1:1370816458
+board1,github:GithubIssue:1:1370833897
+board1,github:GithubIssue:1:1371315795
+board1,github:GithubIssue:1:1371320153
+board1,github:GithubIssue:1:1371541422
+board2,github:GithubIssue:1:1371617668
+board2,github:GithubIssue:1:1372381019
+board3,github:GithubIssue:1:1372550825
+board3,github:GithubIssue:1:1372581663
diff --git a/plugins/dora/e2e/raw_tables/board_repos.csv b/plugins/dora/e2e/raw_tables/board_repos.csv
deleted file mode 100644
index 783022247..000000000
--- a/plugins/dora/e2e/raw_tables/board_repos.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-board_id,repo_id,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-github:GithubRepo:1:384111310,github:GithubRepo:1:384111310,2022-09-15 05:36:33.649,2022-09-15 05:36:33.649,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_repositories,14,""
diff --git a/plugins/dora/e2e/raw_tables/issues.csv b/plugins/dora/e2e/raw_tables/issues.csv
index 62635c572..6b56b27cd 100644
--- a/plugins/dora/e2e/raw_tables/issues.csv
+++ b/plugins/dora/e2e/raw_tables/issues.csv
@@ -1,15 +1,15 @@
-id,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,url,icon_url,issue_key,title,description,epic_key,type,status,original_status,story_point,resolution_date,created_date,updated_date,lead_time_minutes,parent_issue_id,priority,original_estimate_minutes,time_spent_minutes,time_remaining_minutes,creator_id,creator_name,assignee_id,assignee_name,severity,component,deployment_id
-github:GithubIssue:1:1367714738,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3370,"",https://github.com/apache/incubator-devlake/issues/3036,"",3036,[Bug][GitHub Action] The workflow `check-Apache-license-header` doesn't work,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n [...]
-github:GithubIssue:1:1370813347,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3388,"",https://github.com/apache/incubator-devlake/issues/3054,"",3054,[Bug][github] collect apache/incubator-devlake fail,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n### What happened\n\n`` [...]
-github:GithubIssue:1:1370816458,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3389,"",https://github.com/apache/incubator-devlake/issues/3055,"",3055,[Bug][config-ui] cannot create my plugin by advance mode in config-ui,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n### W [...]
-github:GithubIssue:1:1370833897,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3390,"",https://github.com/apache/incubator-devlake/issues/3056,"",3056,[Bug][Framework] github/gitlab/gitee issues do not have  board_repo record,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n [...]
-github:GithubIssue:1:1371315795,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3392,"",https://github.com/apache/incubator-devlake/issues/3058,"",3058,[Feature][Bitbucket] add Pipeline collector & extractor & convertor,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar feature requirement. [...]
-github:GithubIssue:1:1371320153,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3393,"",https://github.com/apache/incubator-devlake/issues/3059,"",3059,[Bug][customize] e2e test failed in postgres,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n### What happened\n\ncached pl [...]
-github:GithubIssue:1:1371541422,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3394,"",https://github.com/apache/incubator-devlake/issues/3060,"",3060,[Bug][Migrationscripts] use common and domainlayer for migrationscripts table model,"""### Search before asking\r\n\r\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar  [...]
-github:GithubIssue:1:1371617668,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3395,"",https://github.com/apache/incubator-devlake/issues/3061,"",3061,[Feature][api-client] wait more time to prevent long-time collection canceled by network problem,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no [...]
-github:GithubIssue:1:1372381019,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3397,"",https://github.com/apache/incubator-devlake/issues/3063,"",3063,[Bug][Bitbucket] the other subtasks cannot continue when the number of issues is zero.,"""### Search before asking\r\n\r\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no simil [...]
-github:GithubIssue:1:1372550825,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3399,"",https://github.com/apache/incubator-devlake/issues/3065,"",3065,[Bug][tapd] error occurred while adding connection for plugin tapd ,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n### Wha [...]
-github:GithubIssue:1:1372581663,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3401,"",https://github.com/apache/incubator-devlake/issues/3067,"",3067,[Bug][Framework] error getting pipelines,"""### Search before asking\r\n\r\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\r\n\r\n\r\n### What happened\r\n\r\ [...]
-github:GithubIssue:1:1372644519,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3402,"",https://github.com/apache/incubator-devlake/issues/3068,"",3068,[Feature][Backend] Establish a standard error logging convention,"""### Search before asking\r\n\r\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar feature requirement [...]
-github:GithubIssue:1:1373079324,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3406,"",https://github.com/apache/incubator-devlake/issues/3072,"",3072,[Bug][framework] status code 500 returned from the server,"""### Search before asking\n\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\n\n\n### What happened [...]
-github:GithubIssue:1:1373792477,2022-09-15 05:36:36.048,2022-09-15 05:36:36.048,"{""ConnectionId"":1,""Owner"":""apache"",""Repo"":""incubator-devlake""}",_raw_github_api_issues,3407,"",https://github.com/apache/incubator-devlake/issues/3073,"",3073,[Bug][github] calculateSince retrun the empty timespace,"""### Search before asking\r\n\r\n- [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.\r\n\r\n\r\n### What  [...]
+id,type,created_date,updated_date
+github:GithubIssue:1:1367714738,INCIDENT,2022-11-13 23:37:21,2022-11-15 22:37:21
+github:GithubIssue:1:1370813347,,2022-09-13 03:52:20,2022-09-15 01:55:52
+github:GithubIssue:1:1370816458,INCIDENT,2022-11-13 01:07:21,2022-11-14 00:07:21
+github:GithubIssue:1:1370833897,,2022-09-13 04:24:57,2022-09-13 06:31:48
+github:GithubIssue:1:1371315795,,2022-09-13 11:44:05,2022-09-13 11:44:05
+github:GithubIssue:1:1371320153,INCIDENT,2022-11-02 08:21:09,2022-11-04 07:21:09
+github:GithubIssue:1:1371541422,,2022-09-13 14:22:20,2022-09-13 14:23:07
+github:GithubIssue:1:1371617668,,2022-09-13 15:14:03,2022-09-13 15:14:03
+github:GithubIssue:1:1372381019,INCIDENT,2022-11-28 01:46:47,2022-11-29 00:46:47
+github:GithubIssue:1:1372550825,FEATURE,2022-09-14 08:10:33,2022-09-14 11:50:20
+github:GithubIssue:1:1372581663,BUG,2022-09-14 08:33:31,2022-09-14 09:11:10
+github:GithubIssue:1:1372644519,INCIDENT,2022-11-16 21:34:01,2022-11-19 20:34:01
+github:GithubIssue:1:1373079324,,2022-09-14 14:25:11,2022-09-14 14:25:25
+github:GithubIssue:1:1373792477,INCIDENT,2022-09-15 01:56:06,2022-09-15 02:13:18
diff --git a/plugins/dora/e2e/raw_tables/lake_cicd_tasks_for_other_jobs.csv b/plugins/dora/e2e/raw_tables/lake_cicd_tasks_for_other_jobs.csv
deleted file mode 100644
index 2d68eec88..000000000
--- a/plugins/dora/e2e/raw_tables/lake_cicd_tasks_for_other_jobs.csv
+++ /dev/null
@@ -1,22 +0,0 @@
-id,name,pipeline_id,result,status,type,environment,duration_sec,started_date,finished_date
-github:GithubJob:1:8269045794,lint,github:GithubRun:1:3022052551,FAILURE,DONE,,,72,2022-09-09T11:27:13.000+00:00,2022-09-09T11:28:25.000+00:00
-github:GithubJob:1:8269045795,test (ubuntu-latest),github:GithubRun:1:3022052557,SUCCESS,DONE,,,191,2022-09-09T11:27:42.000+00:00,2022-09-09T11:30:53.000+00:00
-github:GithubJob:1:8269045819,commit-msg,github:GithubRun:1:3022052555,SUCCESS,DONE,,,8,2022-09-09T11:26:38.000+00:00,2022-09-09T11:26:46.000+00:00
-github:GithubJob:1:8269045928,e2e-mysql,github:GithubRun:1:3022052558,SUCCESS,DONE,,,200,2022-09-09T11:28:00.000+00:00,2022-09-09T11:31:20.000+00:00
-github:GithubJob:1:8269046116,check Apache license header,github:GithubRun:1:3022052589,SUCCESS,DONE,,,57,2022-09-09T11:28:34.000+00:00,2022-09-09T11:29:31.000+00:00
-github:GithubJob:1:8269415129,lint,github:GithubRun:1:3022190519,FAILURE,DONE,,,84,2022-09-09T11:51:21.000+00:00,2022-09-09T11:52:45.000+00:00
-github:GithubJob:1:8269415130,test (ubuntu-latest),github:GithubRun:1:3022190524,SUCCESS,DONE,,,182,2022-09-09T11:50:31.000+00:00,2022-09-09T11:53:33.000+00:00
-github:GithubJob:1:8269415142,check Apache license header,github:GithubRun:1:3022190525,SUCCESS,DONE,,,63,2022-09-09T11:52:06.000+00:00,2022-09-09T11:53:09.000+00:00
-github:GithubJob:1:8269415165,commit-msg,github:GithubRun:1:3022190521,SUCCESS,DONE,,,10,2022-09-09T11:52:46.000+00:00,2022-09-09T11:52:56.000+00:00
-github:GithubJob:1:8269415315,e2e-mysql,github:GithubRun:1:3022190520,SUCCESS,DONE,,,242,2022-09-09T11:53:45.000+00:00,2022-09-09T11:57:47.000+00:00
-github:GithubJob:1:8269598312,e2e-mysql,github:GithubRun:1:3022255519,SUCCESS,DONE,,,828,2022-09-09T12:05:04.000+00:00,2022-09-09T12:18:52.000+00:00
-github:GithubJob:1:8269598316,test (ubuntu-latest),github:GithubRun:1:3022255511,SUCCESS,DONE,,,1016,2022-09-09T12:05:49.000+00:00,2022-09-09T12:22:45.000+00:00
-github:GithubJob:1:8269598318,lint,github:GithubRun:1:3022255516,FAILURE,DONE,,,62,2022-09-09T12:02:28.000+00:00,2022-09-09T12:03:30.000+00:00
-github:GithubJob:1:8269598325,check Apache license header,github:GithubRun:1:3022255517,SUCCESS,DONE,,,52,2022-09-09T12:03:51.000+00:00,2022-09-09T12:04:43.000+00:00
-github:GithubJob:1:8269598469,commit-msg,github:GithubRun:1:3022255524,FAILURE,DONE,,,41,2022-09-09T12:06:55.000+00:00,2022-09-09T12:07:36.000+00:00
-github:GithubJob:1:8269729324,e2e-mysql,github:GithubRun:1:3022300995,SUCCESS,DONE,,,1007,2022-09-09T12:10:08.000+00:00,2022-09-09T12:26:55.000+00:00
-github:GithubJob:1:8269729327,xx_deploy_xx,github:GithubRun:1:3022301001,FAILURE,DONE,DEPLOY,staging,82,2022-09-09T12:11:22.000+00:00,2022-09-09T12:12:44.000+00:00
-github:GithubJob:1:8269729550,build_deployment,github:GithubRun:1:3022301007,SUCCESS,DONE,DEPLOY,staging,6,2022-09-09T12:12:02.000+00:00,2022-09-09T12:12:08.000+00:00
-github:GithubJob:1:8269729553,build_deploy,github:GithubRun:1:3022300997,SUCCESS,DONE,DEPLOY,staging,57,2022-09-09T12:12:52.000+00:00,2022-09-09T12:13:49.000+00:00
-github:GithubJob:1:8269729821,deployment,github:GithubRun:1:3022301033,SUCCESS,DONE,DEPLOY,staging,991,2022-09-09T12:13:58.000+00:00,2022-09-09T12:30:29.000+00:00
-github:GithubJob:1:8269872730,deploy,github:GithubRun:1:3022348786,SUCCESS,DONE,DEPLOY,staging,1006,2022-09-09T12:21:30.000+00:00,2022-09-09T12:38:16.000+00:00
diff --git a/plugins/dora/e2e/raw_tables/project_mapping.csv b/plugins/dora/e2e/raw_tables/project_mapping.csv
index bcc085fc9..296ab9e2f 100644
--- a/plugins/dora/e2e/raw_tables/project_mapping.csv
+++ b/plugins/dora/e2e/raw_tables/project_mapping.csv
@@ -4,3 +4,6 @@ project1,cicd_scopes,cicd2
 project1,repos,repo1
 project1,repos,repo2
 project2,cicd_scopes,cicd3
+project1,boards,board1
+project1,boards,board2
+project2,boards,board3
\ No newline at end of file
diff --git a/plugins/dora/e2e/snapshot_tables/project_issue_metrics.csv b/plugins/dora/e2e/snapshot_tables/project_issue_metrics.csv
new file mode 100644
index 000000000..dc93a25c9
--- /dev/null
+++ b/plugins/dora/e2e/snapshot_tables/project_issue_metrics.csv
@@ -0,0 +1,5 @@
+id,project_name,deployment_id
+github:GithubIssue:1:1367714738,project1,task10
+github:GithubIssue:1:1370816458,project1,task11
+github:GithubIssue:1:1371320153,project1,task12
+github:GithubIssue:1:1372381019,project1,task13
diff --git a/plugins/dora/impl/impl.go b/plugins/dora/impl/impl.go
index 394d4d9cc..fd45d58da 100644
--- a/plugins/dora/impl/impl.go
+++ b/plugins/dora/impl/impl.go
@@ -91,7 +91,7 @@ func (plugin Dora) SubTaskMetas() []core.SubTaskMeta {
 	return []core.SubTaskMeta{
 		tasks.EnrichTaskEnvMeta,
 		tasks.CalculateChangeLeadTimeMeta,
-		tasks.ConnectIssueDeployMeta,
+		tasks.ConnectIncidentToDeploymentMeta,
 	}
 }
 
diff --git a/plugins/dora/tasks/change_lead_time_calculator.go b/plugins/dora/tasks/change_lead_time_calculator.go
index 33e80f5da..dd5f77bd3 100644
--- a/plugins/dora/tasks/change_lead_time_calculator.go
+++ b/plugins/dora/tasks/change_lead_time_calculator.go
@@ -20,6 +20,7 @@ package tasks
 import (
 	goerror "errors"
 	"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
+	"github.com/apache/incubator-devlake/models/domainlayer/devops"
 	"reflect"
 	"time"
 
@@ -43,7 +44,7 @@ func CalculateChangeLeadTime(taskCtx core.SubTaskContext) errors.Error {
 		dal.Join(`left join cicd_pipeline_commits cpc on ct.pipeline_id = cpc.pipeline_id`),
 		dal.Join(`left join project_mapping pm on pm.row_id = ct.cicd_scope_id`),
 		dal.Where(`ct.environment = ? and ct.type = ? and ct.result = ? and pm.project_name = ? and pm.table = ?`,
-			"PRODUCTION", "DEPLOYMENT", "SUCCESS", data.Options.ProjectName, "cicd_scopes"),
+			devops.PRODUCTION, devops.DEPLOYMENT, devops.SUCCESS, data.Options.ProjectName, "cicd_scopes"),
 		dal.Orderby(`cpc.repo_id, ct.started_date `),
 	}
 	deploymentPairList := make([]deploymentPair, 0)
diff --git a/plugins/dora/tasks/issue_deploy_connector.go b/plugins/dora/tasks/incident_deploy_connector.go
similarity index 60%
rename from plugins/dora/tasks/issue_deploy_connector.go
rename to plugins/dora/tasks/incident_deploy_connector.go
index 180e49ff6..52123cf1f 100644
--- a/plugins/dora/tasks/issue_deploy_connector.go
+++ b/plugins/dora/tasks/incident_deploy_connector.go
@@ -19,6 +19,8 @@ package tasks
 
 import (
 	goerror "errors"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
 	"reflect"
 
 	"github.com/apache/incubator-devlake/errors"
@@ -30,22 +32,25 @@ import (
 	"gorm.io/gorm"
 )
 
-var ConnectIssueDeployMeta = core.SubTaskMeta{
-	Name:             "ConnectIssueDeploy",
-	EntryPoint:       ConnectIssueDeploy,
+var ConnectIncidentToDeploymentMeta = core.SubTaskMeta{
+	Name:             "ConnectIncidentToDeployment",
+	EntryPoint:       ConnectIncidentToDeployment,
 	EnabledByDefault: true,
-	Description:      "TODO",
+	Description:      "Connect incident issue to deployment",
 	DomainTypes:      []string{core.DOMAIN_TYPE_CICD},
 }
 
-func ConnectIssueDeploy(taskCtx core.SubTaskContext) errors.Error {
+func ConnectIncidentToDeployment(taskCtx core.SubTaskContext) errors.Error {
 	db := taskCtx.GetDal()
-	issue := &ticket.Issue{}
+	data := taskCtx.GetData().(*DoraTaskData)
 	// select all issues belongs to the board
 	clauses := []dal.Clause{
-		dal.From(issue),
+		dal.From(`issues i`),
+		dal.Join(`left join board_issues bi on bi.issue_id = i.id`),
+		dal.Join(`left join project_mapping pm on pm.row_id = bi.board_id`),
 		dal.Where(
-			"issues.type = ?", "INCIDENT",
+			"i.type = ? and pm.project_name = ? and pm.table = ?",
+			"INCIDENT", data.Options.ProjectName, "boards",
 		),
 	}
 	cursor, err := db.Cursor(clauses...)
@@ -56,24 +61,34 @@ func ConnectIssueDeploy(taskCtx core.SubTaskContext) errors.Error {
 
 	enricher, err := helper.NewDataConverter(helper.DataConverterArgs{
 		RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
-			Ctx:    taskCtx,
+			Ctx: taskCtx,
 			Params: DoraApiParams{
-				// TODO
+				ProjectName: data.Options.ProjectName,
 			},
 			Table: "issues",
 		},
 		InputRowType: reflect.TypeOf(ticket.Issue{}),
 		Input:        cursor,
 		Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
-			issueToBeUpdate := inputRow.(*ticket.Issue)
+			issue := inputRow.(*ticket.Issue)
+			projectIssueMetric := &crossdomain.ProjectIssueMetric{
+				DomainEntity: domainlayer.DomainEntity{
+					Id: issue.Id,
+				},
+				ProjectName: data.Options.ProjectName,
+			}
 			cicdTask := &devops.CICDTask{}
 			cicdTakClauses := []dal.Clause{
 				dal.From(cicdTask),
-				dal.Join("left join cicd_pipeline_commits on cicd_tasks.pipeline_id = cicd_pipeline_commits.pipeline_id"),
+				dal.Join("left join project_mapping pm on cicd_tasks.cicd_scope_id = pm.row_id"),
 				dal.Where(
 					`cicd_tasks.finished_date < ? 
-								and cicd_tasks.result = ? and cicd_tasks.environment = ?`,
-					issueToBeUpdate.CreatedDate, "SUCCESS", devops.PRODUCTION,
+								and cicd_tasks.result = ? 
+								and cicd_tasks.environment = ?
+								and cicd_tasks.type = ?
+								and pm.table = ?
+								and pm.project_name = ?`,
+					issue.CreatedDate, devops.SUCCESS, devops.PRODUCTION, devops.DEPLOYMENT, "cicd_scopes", data.Options.ProjectName,
 				),
 				dal.Orderby("cicd_tasks.finished_date DESC"),
 			}
@@ -85,9 +100,9 @@ func ConnectIssueDeploy(taskCtx core.SubTaskContext) errors.Error {
 					return nil, err
 				}
 			}
-			issueToBeUpdate.DeploymentId = cicdTask.Id
+			projectIssueMetric.DeploymentId = cicdTask.Id
 
-			return []interface{}{issueToBeUpdate}, nil
+			return []interface{}{projectIssueMetric}, nil
 		},
 	})
 	if err != nil {