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

zky 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 2980f6162 fix: deployment_commit_generator produced unwanted records 
(#5028)
2980f6162 is described below

commit 2980f6162c2c0f69a6f895e37803b3056b07eee7
Author: Klesh Wong <[email protected]>
AuthorDate: Tue Apr 25 16:01:26 2023 +0800

    fix: deployment_commit_generator produced unwanted records (#5028)
---
 .../dora/tasks/deployment_commits_generator.go     | 44 +++++++++++++---------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/backend/plugins/dora/tasks/deployment_commits_generator.go 
b/backend/plugins/dora/tasks/deployment_commits_generator.go
index f8f1cef7d..ffbb5501d 100644
--- a/backend/plugins/dora/tasks/deployment_commits_generator.go
+++ b/backend/plugins/dora/tasks/deployment_commits_generator.go
@@ -59,22 +59,27 @@ func GenerateDeploymentCommits(taskCtx 
plugin.SubTaskContext) errors.Error {
        // select all cicd_pipeline_commits from all "Deployments" in the 
project
        // Note that failed records shall be included as well
        cursor, err := db.Cursor(
-               dal.Select(`
-                       pc.*, p.name as pipeline_name,
-                       p.result,
-                       p.status,
-                       p.duration_sec,
-                       p.created_date,
-                       p.finished_date,
-                       p.environment,
-                       p.cicd_scope_id,
-                       EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = 
p.id AND t.environment = ?)
-                        as has_testing_tasks,
-                       EXISTS(SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id = 
p.id AND t.environment = ?)
-                        as has_staging_tasks,
-                       EXISTS( SELECT 1 FROM cicd_tasks t WHERE t.pipeline_id 
= p.id AND t.environment = ?)
-                        as has_production_tasks
-               `),
+               dal.Select(
+                       `
+                               pc.*, p.name as pipeline_name,
+                               p.result,
+                               p.status,
+                               p.duration_sec,
+                               p.created_date,
+                               p.finished_date,
+                               p.environment,
+                               p.cicd_scope_id,
+                               EXISTS(SELECT 1 FROM cicd_tasks t WHERE 
t.pipeline_id = p.id AND t.environment = ?)
+                               as has_testing_tasks,
+                               EXISTS(SELECT 1 FROM cicd_tasks t WHERE 
t.pipeline_id = p.id AND t.environment = ?)
+                               as has_staging_tasks,
+                               EXISTS( SELECT 1 FROM cicd_tasks t WHERE 
t.pipeline_id = p.id AND t.environment = ?)
+                               as has_production_tasks
+                       `,
+                       devops.TESTING,
+                       devops.STAGING,
+                       devops.PRODUCTION,
+               ),
                dal.From("cicd_pipeline_commits pc"),
                dal.Join("LEFT JOIN cicd_pipelines p ON (p.id = 
pc.pipeline_id)"),
                dal.Join("LEFT JOIN project_mapping pm ON (pm.table = 
'cicd_scopes' AND pm.row_id = p.cicd_scope_id)"),
@@ -82,10 +87,13 @@ func GenerateDeploymentCommits(taskCtx 
plugin.SubTaskContext) errors.Error {
                        `
                        pm.project_name = ? AND (
                                p.type = ? OR EXISTS(
-                                       SELECT 1 FROM cicd_tasks t WHERE 
t.pipeline_id = p.id AND t.type = p.type
+                                       SELECT 1 FROM cicd_tasks t WHERE 
t.pipeline_id = p.id AND t.type = ?
                                )
                        )
-                       `, devops.TESTING, devops.STAGING, devops.PRODUCTION, 
data.Options.ProjectName, devops.DEPLOYMENT,
+                       `,
+                       data.Options.ProjectName,
+                       devops.DEPLOYMENT,
+                       devops.DEPLOYMENT,
                ),
        )
        if err != nil {

Reply via email to