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

abeizn pushed a commit to branch feat-issue-trace-to-jira
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/feat-issue-trace-to-jira by 
this push:
     new a2d939a9c feat: issue trace move to jira plugin
a2d939a9c is described below

commit a2d939a9c702ef8d6c3f21930eee53eb7e2a0e78
Author: abeizn <[email protected]>
AuthorDate: Fri Sep 27 14:45:42 2024 +0800

    feat: issue trace move to jira plugin
---
 backend/plugins/jira/api/blueprint_v200.go         | 19 ++++++++-
 ...40926_add_enable_issue_trace_to_scope_config.go | 46 ++++++++++++++++++++++
 .../jira/models/migrationscripts/register.go       |  1 +
 backend/plugins/jira/models/scope_config.go        |  1 +
 4 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/backend/plugins/jira/api/blueprint_v200.go 
b/backend/plugins/jira/api/blueprint_v200.go
index 3d840642c..01ed8331d 100644
--- a/backend/plugins/jira/api/blueprint_v200.go
+++ b/backend/plugins/jira/api/blueprint_v200.go
@@ -95,8 +95,25 @@ func makeDataSourcePipelinePlanV200(
                if err != nil {
                        return nil, err
                }
-
                stage = append(stage, task)
+
+               // add issue_trace stage
+               if scopeConfig == nil || scopeConfig.EnableIssueTrace == nil || 
*scopeConfig.EnableIssueTrace {
+                       j := i + 1
+                       if j == len(plan) {
+                               plan = append(plan, nil)
+                       }
+                       plan[j] = coreModels.PipelineStage{
+                               {
+                                       Plugin: "issue_trace",
+                                       Options: map[string]interface{}{
+                                               "plugin":       "issue_trace",
+                                               "connectionId": connection.ID,
+                                               "boardId":      scope.BoardId,
+                                       },
+                               },
+                       }
+               }
                plan[i] = stage
        }
 
diff --git 
a/backend/plugins/jira/models/migrationscripts/20240926_add_enable_issue_trace_to_scope_config.go
 
b/backend/plugins/jira/models/migrationscripts/20240926_add_enable_issue_trace_to_scope_config.go
new file mode 100644
index 000000000..182ca7dd7
--- /dev/null
+++ 
b/backend/plugins/jira/models/migrationscripts/20240926_add_enable_issue_trace_to_scope_config.go
@@ -0,0 +1,46 @@
+/*
+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/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+type jiraScopeConfig20240926 struct {
+       EnableIssueTrace *bool `json:"enableIssueTrace" gorm:"type:boolean"`
+}
+
+func (jiraScopeConfig20240926) TableName() string {
+       return "_tool_jira_scope_configs"
+}
+
+type addEnableIssueTrace20240926 struct{}
+
+func (script *addEnableIssueTrace20240926) Up(basicRes context.BasicRes) 
errors.Error {
+       return migrationhelper.AutoMigrateTables(basicRes, 
&jiraScopeConfig20240926{})
+}
+
+func (*addEnableIssueTrace20240926) Version() uint64 {
+       return 20240926142316
+}
+
+func (*addEnableIssueTrace20240926) Name() string {
+       return "add enable_issue_trace to scope config"
+}
diff --git a/backend/plugins/jira/models/migrationscripts/register.go 
b/backend/plugins/jira/models/migrationscripts/register.go
index 8d088b262..3fd606bfd 100644
--- a/backend/plugins/jira/models/migrationscripts/register.go
+++ b/backend/plugins/jira/models/migrationscripts/register.go
@@ -54,5 +54,6 @@ func All() []plugin.MigrationScript {
                new(changeIssueComponentType),
                new(flushJiraIssues),
                new(addJiraServerInfo),
+               new(addEnableIssueTrace20240926),
        }
 }
diff --git a/backend/plugins/jira/models/scope_config.go 
b/backend/plugins/jira/models/scope_config.go
index bb267a0f6..5135f6e5e 100644
--- a/backend/plugins/jira/models/scope_config.go
+++ b/backend/plugins/jira/models/scope_config.go
@@ -48,6 +48,7 @@ type JiraScopeConfig struct {
        RemotelinkRepoPattern      []CommitUrlPattern     
`mapstructure:"remotelinkRepoPattern,omitempty" json:"remotelinkRepoPattern" 
gorm:"type:json;serializer:json"`
        TypeMappings               map[string]TypeMapping 
`mapstructure:"typeMappings,omitempty" json:"typeMappings" 
gorm:"type:json;serializer:json"`
        ApplicationType            string                 
`mapstructure:"applicationType,omitempty" json:"applicationType" 
gorm:"type:varchar(255)"`
+       EnableIssueTrace           *bool                  
`mapstructure:"enableIssueTrace,omitempty" json:"enableIssueTrace" 
gorm:"type:boolean"`
 }
 
 func (r *JiraScopeConfig) SetConnectionId(c *JiraScopeConfig, connectionId 
uint64) {

Reply via email to