You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/06/17 03:15:40 UTC
[incubator-devlake] 01/02: add jira issue label
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch release-v0.11-hotfix
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit b4d52c053cfa62d8c04ec5eb7d2471be032efbe0
Author: moon.li <mo...@paytm.com>
AuthorDate: Thu Jun 16 17:17:40 2022 +0800
add jira issue label
Signed-off-by: moon.li <mo...@paytm.com>
---
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, 82 insertions(+), 2 deletions(-)
diff --git a/plugins/jira/jira.go b/plugins/jira/jira.go
index 6fe00730..92a9a9aa 100644
--- a/plugins/jira/jira.go
+++ b/plugins/jira/jira.go
@@ -156,7 +156,6 @@ func (plugin Jira) MigrationScripts() []migration.Script {
new(migrationscripts.UpdateSchemas20220525),
new(migrationscripts.UpdateSchemas20220526),
new(migrationscripts.UpdateSchemas20220527),
- new(migrationscripts.UpdateSchemas20220614),
}
}
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 c6a70d80..9efafde7 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 62acc4f7..e0e235eb 100644
--- a/plugins/jira/tasks/issue_extractor.go
+++ b/plugins/jira/tasks/issue_extractor.go
@@ -135,6 +135,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
},
})