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

warren 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 317c9250 add jira issue label
317c9250 is described below

commit 317c9250ea6c619abccc94472b5aa3280b46aebb
Author: moon.li <[email protected]>
AuthorDate: Thu Jun 16 17:17:40 2022 +0800

    add jira issue label
    
    Signed-off-by: moon.li <[email protected]>
---
 plugins/jira/jira.go                               |  1 +
 plugins/jira/models/issue_label.go                 | 19 ++++++++
 .../migrationscripts/updateSchemas20220616.go      | 52 ++++++++++++++++++++++
 plugins/jira/tasks/apiv2models/issue.go            |  2 +-
 plugins/jira/tasks/issue_extractor.go              | 10 +++++
 5 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/plugins/jira/jira.go b/plugins/jira/jira.go
index dd3ab769..828c0baf 100644
--- a/plugins/jira/jira.go
+++ b/plugins/jira/jira.go
@@ -168,6 +168,7 @@ func (plugin Jira) MigrationScripts() []migration.Script {
                new(migrationscripts.UpdateSchemas20220527),
                new(migrationscripts.UpdateSchemas20220601),
                new(migrationscripts.UpdateSchemas20220614),
+               new(migrationscripts.UpdateSchemas20220616),
        }
 }
 
diff --git a/plugins/jira/models/issue_label.go 
b/plugins/jira/models/issue_label.go
new file mode 100644
index 00000000..0f9cfbdd
--- /dev/null
+++ b/plugins/jira/models/issue_label.go
@@ -0,0 +1,19 @@
+package models
+
+import (
+       "github.com/apache/incubator-devlake/models/common"
+)
+
+// Please note that Issue Labels can also apply to Pull Requests.
+// Pull Requests are considered Issues in GitHub.
+
+type JiraIssueLabel struct {
+       ConnectionId uint64 `gorm:"primaryKey;autoIncrement:false"`
+       IssueId      uint64 `gorm:"primaryKey;autoIncrement:false"`
+       LabelName    string `gorm:"primaryKey;type:varchar(255)"`
+       common.NoPKModel
+}
+
+func (JiraIssueLabel) TableName() string {
+       return "_tool_jira_issue_labels"
+}
diff --git a/plugins/jira/models/migrationscripts/updateSchemas20220616.go 
b/plugins/jira/models/migrationscripts/updateSchemas20220616.go
new file mode 100644
index 00000000..a02f7fda
--- /dev/null
+++ b/plugins/jira/models/migrationscripts/updateSchemas20220616.go
@@ -0,0 +1,52 @@
+/*
+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 (
+       "context"
+       "github.com/apache/incubator-devlake/models/migrationscripts/archived"
+
+       "gorm.io/gorm"
+)
+
+type JiraIssueLabel0616 struct {
+       ConnectionId uint64 `gorm:"primaryKey;autoIncrement:false"`
+       IssueId      uint64 `gorm:"primaryKey;autoIncrement:false"`
+       LabelName    string `gorm:"primaryKey;type:varchar(255)"`
+       archived.NoPKModel
+}
+
+func (JiraIssueLabel0616) TableName() string {
+       return "_tool_jira_issue_labels"
+}
+
+type UpdateSchemas20220616 struct{}
+
+func (*UpdateSchemas20220616) Up(ctx context.Context, db *gorm.DB) error {
+
+       err := db.Migrator().AutoMigrate(JiraIssueLabel0616{})
+       return err
+}
+
+func (*UpdateSchemas20220616) Version() uint64 {
+       return 20220616154646
+}
+
+func (*UpdateSchemas20220616) Name() string {
+       return "add jira issue labels"
+}
diff --git a/plugins/jira/tasks/apiv2models/issue.go 
b/plugins/jira/tasks/apiv2models/issue.go
index cfd52916..a110bbd6 100644
--- a/plugins/jira/tasks/apiv2models/issue.go
+++ b/plugins/jira/tasks/apiv2models/issue.go
@@ -91,7 +91,7 @@ type Issue struct {
                        Name    string `json:"name"`
                        ID      uint64 `json:"id,string"`
                } `json:"priority"`
-               Labels                        []interface{}      `json:"labels"`
+               Labels                        []string           `json:"labels"`
                Timeestimate                  interface{}        
`json:"timeestimate"`
                Aggregatetimeoriginalestimate interface{}        
`json:"aggregatetimeoriginalestimate"`
                Versions                      []interface{}      
`json:"versions"`
diff --git a/plugins/jira/tasks/issue_extractor.go 
b/plugins/jira/tasks/issue_extractor.go
index 3c2cee56..98c0df49 100644
--- a/plugins/jira/tasks/issue_extractor.go
+++ b/plugins/jira/tasks/issue_extractor.go
@@ -141,6 +141,16 @@ func ExtractIssues(taskCtx core.SubTaskContext) error {
                                BoardId:      boardId,
                                IssueId:      issue.IssueId,
                        })
+                       labels := apiIssue.Fields.Labels
+                       for _, v := range labels {
+                               issueLabel := &models.JiraIssueLabel{
+                                       IssueId:      issue.IssueId,
+                                       LabelName:    v,
+                                       ConnectionId: data.Options.ConnectionId,
+                               }
+                               results = append(results, issueLabel)
+                       }
+                       return results, nil
                        return results, nil
                },
        })

Reply via email to