This is an automated email from the ASF dual-hosted git repository.
klesh 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 1502349b1 fix: some zentao bugs (#5620)
1502349b1 is described below
commit 1502349b1427f34102afa736172282cddcbd05e5
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jul 4 12:13:37 2023 +0800
fix: some zentao bugs (#5620)
---
.../e2e/snapshot_tables/bug_issue_assignees.csv | 1 -
.../zentao/e2e/snapshot_tables/issues_bug.csv | 2 +-
.../zentao/e2e/snapshot_tables/issues_story.csv | 10 ++--
.../zentao/e2e/snapshot_tables/issues_task.csv | 6 +--
.../e2e/snapshot_tables/story_issue_assignees.csv | 10 ++--
.../e2e/snapshot_tables/task_issue_assignees.csv | 6 +--
backend/plugins/zentao/tasks/bug_convertor.go | 17 +++---
.../plugins/zentao/tasks/changelog_convertor.go | 63 ++++++++++++++++++++++
backend/plugins/zentao/tasks/shared.go | 1 -
backend/plugins/zentao/tasks/story_convertor.go | 47 ++++++++--------
backend/plugins/zentao/tasks/task_convertor.go | 53 +++++++++---------
11 files changed, 138 insertions(+), 78 deletions(-)
diff --git a/backend/plugins/zentao/e2e/snapshot_tables/bug_issue_assignees.csv
b/backend/plugins/zentao/e2e/snapshot_tables/bug_issue_assignees.csv
index 813c4a7b0..34d012ae5 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/bug_issue_assignees.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/bug_issue_assignees.csv
@@ -1,4 +1,3 @@
issue_id,assignee_id,assignee_name
zentao:ZentaoBug:1:1,zentao:ZentaoAccount:1:4,开发甲
-zentao:ZentaoBug:1:2,zentao:ZentaoAccount:1:0,
zentao:ZentaoBug:1:4,zentao:ZentaoAccount:1:9,测试丙
diff --git a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv
b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv
index 9c5c225e4..4d877d06c 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv
@@ -1,4 +1,4 @@
id,url,icon_url,issue_key,title,description,epic_key,type,original_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
zentao:ZentaoBug:1:1,http://iwater.red:8000/api.php/v1/products/1/bugs?limit=100&page=1,,1,首页页面问题,,,BUG,codeerror,DONE,active,0,,2012-06-05T02:56:11.000+00:00,2021-04-28T03:09:08.000+00:00,0,zentao:ZentaoStory:1:1,1,0,0,0,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:4,开发甲,,
-zentao:ZentaoBug:1:2,http://iwater.red:8000/api.php/v1/products/1/bugs?limit=100&page=1,,2,新闻中心页面问题,,,BUG,codeerror,,delay,0,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,0,zentao:ZentaoStory:1:2,2,0,0,0,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:0,,,
+zentao:ZentaoBug:1:2,http://iwater.red:8000/api.php/v1/products/1/bugs?limit=100&page=1,,2,新闻中心页面问题,,,BUG,codeerror,,delay,0,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,0,zentao:ZentaoStory:1:2,2,0,0,0,zentao:ZentaoAccount:1:7,测试甲,"",,,
zentao:ZentaoBug:1:4,http://iwater.red:8000/api.php/v1/products/1/bugs?limit=100&page=1,,4,售后服务页面问题,,,BUG,codeerror,,resolved,0,,2012-06-05T03:00:19.000+00:00,2022-10-05T04:10:08.000+00:00,0,zentao:ZentaoStory:1:4,1,0,0,0,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoAccount:1:9,测试丙,,
diff --git a/backend/plugins/zentao/e2e/snapshot_tables/issues_story.csv
b/backend/plugins/zentao/e2e/snapshot_tables/issues_story.csv
index 847fd2df8..a819f44fe 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/issues_story.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/issues_story.csv
@@ -1,6 +1,6 @@
id,url,icon_url,issue_key,title,description,epic_key,type,original_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
-zentao:ZentaoStory:1:1,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,1,首页设计和开发,,,REQUIREMENT,story.feature,,active-developing,0,,2012-06-05T02:09:49.000+00:00,2012-06-05T02:25:19.000+00:00,0,,1,60,0,0,zentao:ZentaoAccount:1,产品经理,zentao:ZentaoAccount:1,产品经理,,
-zentao:ZentaoStory:1:3,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,3,成果展示的设计和开发,,,REQUIREMENT,story.feature,,active-developing,0,,2012-06-05T02:18:10.000+00:00,2012-06-05T02:25:38.000+00:00,0,,1,0,0,0,zentao:ZentaoAccount:1,产品经理,zentao:ZentaoAccount:1,产品经理,,
-zentao:ZentaoStory:1:4,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,4,售后服务的设计和开发,,,REQUIREMENT,story.feature,,active-developed,0,,2012-06-05T02:20:16.000+00:00,2012-06-05T02:25:42.000+00:00,0,,1,60,0,0,zentao:ZentaoAccount:1,产品经理,zentao:ZentaoAccount:1,产品经理,,
-zentao:ZentaoStory:1:6,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,6,合作洽谈的设计和开发,,,REQUIREMENT,story.feature,,reviewing-planned,0,,2012-06-05T02:23:11.000+00:00,,0,,1,60,0,0,zentao:ZentaoAccount:1,产品经理,zentao:ZentaoAccount:1,产品经理,,
-zentao:ZentaoStory:1:7,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,7,关于我们的设计和开发,,,REQUIREMENT,story.feature,,reviewing-planned,0,,2012-06-05T02:24:19.000+00:00,,0,,1,60,0,0,zentao:ZentaoAccount:1,产品经理,zentao:ZentaoAccount:1,产品经理,,
+zentao:ZentaoStory:1:1,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,1,首页设计和开发,,,REQUIREMENT,story.feature,,active,0,,2012-06-05T02:09:49.000+00:00,2012-06-05T02:25:19.000+00:00,0,,1,0,0,0,zentao:ZentaoAccount:1:2,产品经理,zentao:ZentaoAccount:1:2,产品经理,,
+zentao:ZentaoStory:1:3,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,3,成果展示的设计和开发,,,REQUIREMENT,story.feature,,active,0,,2012-06-05T02:18:10.000+00:00,2012-06-05T02:25:38.000+00:00,0,,1,0,0,0,zentao:ZentaoAccount:1:2,产品经理,zentao:ZentaoAccount:1:2,产品经理,,
+zentao:ZentaoStory:1:4,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,4,售后服务的设计和开发,,,REQUIREMENT,story.feature,,active,0,,2012-06-05T02:20:16.000+00:00,2012-06-05T02:25:42.000+00:00,0,,1,0,0,0,zentao:ZentaoAccount:1:2,产品经理,zentao:ZentaoAccount:1:2,产品经理,,
+zentao:ZentaoStory:1:6,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,6,合作洽谈的设计和开发,,,REQUIREMENT,story.feature,,reviewing,0,,2012-06-05T02:23:11.000+00:00,,0,,1,0,0,0,zentao:ZentaoAccount:1:2,产品经理,zentao:ZentaoAccount:1:2,产品经理,,
+zentao:ZentaoStory:1:7,http://iwater.red:8000/api.php/v1/products/1/stories?limit=100&page=1,,7,关于我们的设计和开发,,,REQUIREMENT,story.feature,,reviewing,0,,2012-06-05T02:24:19.000+00:00,,0,,1,0,0,0,zentao:ZentaoAccount:1:2,产品经理,zentao:ZentaoAccount:1:2,产品经理,,
diff --git a/backend/plugins/zentao/e2e/snapshot_tables/issues_task.csv
b/backend/plugins/zentao/e2e/snapshot_tables/issues_task.csv
index ec61da8a8..070797b79 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/issues_task.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/issues_task.csv
@@ -1,4 +1,4 @@
id,url,icon_url,issue_key,title,description,epic_key,type,original_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
-zentao:ZentaoTask:1:1,http://iwater.red:8000/api.php/v1/executions/9/tasks?limit=100&page=1,,1,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,0,zentao:ZentaoStory:1:0,3,0,0,0,zentao:ZentaoAccount:1,devlake,zentao:ZentaoAccount:1,开发乙,,
-zentao:ZentaoTask:1:2,http://iwater.red:8000/api.php/v1/executions/4/tasks?limit=100&page=1,,2,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,600,zentao:ZentaoStory:1:0,3,726,126,0,zentao:ZentaoAccount:1,devlake,zentao:ZentaoAccount:1,开发乙,,
-zentao:ZentaoTask:1:3,http://iwater.red:8000/api.php/v1/executions/3/tasks?limit=100&page=1,,3,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,0,zentao:ZentaoStory:1:-1,3,672,0,0,zentao:ZentaoAccount:1,devlake,zentao:ZentaoAccount:1,开发乙,,
+zentao:ZentaoTask:1:1,http://iwater.red:8000/api.php/v1/executions/9/tasks?limit=100&page=1,,1,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel.,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,0,,3,0,0,0,zentao:ZentaoAccount:1:1,devlake,zentao:ZentaoAccount:1:5,开发乙,,
+zentao:ZentaoTask:1:2,http://iwater.red:8000/api.php/v1/executions/4/tasks?limit=100&page=1,,2,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel.,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,0,,3,0,0,0,zentao:ZentaoAccount:1:1,devlake,zentao:ZentaoAccount:1:5,开发乙,,
+zentao:ZentaoTask:1:3,http://iwater.red:8000/api.php/v1/executions/3/tasks?limit=100&page=1,,3,任务名称,任务描述<span>
</span><br /><div><br
/></div>,,TASK,devel.,IN_PROGRESS,wait,0,,2022-09-19T01:50:37.000+00:00,,0,zentao:ZentaoStory:1:-1,3,0,0,0,zentao:ZentaoAccount:1:1,devlake,zentao:ZentaoAccount:1:5,开发乙,,
diff --git
a/backend/plugins/zentao/e2e/snapshot_tables/story_issue_assignees.csv
b/backend/plugins/zentao/e2e/snapshot_tables/story_issue_assignees.csv
index 7668715ab..800310178 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/story_issue_assignees.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/story_issue_assignees.csv
@@ -1,6 +1,6 @@
issue_id,assignee_id,assignee_name
-zentao:ZentaoStory:1:1,zentao:ZentaoAccount:1,产品经理
-zentao:ZentaoStory:1:3,zentao:ZentaoAccount:1,产品经理
-zentao:ZentaoStory:1:4,zentao:ZentaoAccount:1,产品经理
-zentao:ZentaoStory:1:6,zentao:ZentaoAccount:1,产品经理
-zentao:ZentaoStory:1:7,zentao:ZentaoAccount:1,产品经理
+zentao:ZentaoStory:1:1,zentao:ZentaoAccount:1:2,产品经理
+zentao:ZentaoStory:1:3,zentao:ZentaoAccount:1:2,产品经理
+zentao:ZentaoStory:1:4,zentao:ZentaoAccount:1:2,产品经理
+zentao:ZentaoStory:1:6,zentao:ZentaoAccount:1:2,产品经理
+zentao:ZentaoStory:1:7,zentao:ZentaoAccount:1:2,产品经理
diff --git
a/backend/plugins/zentao/e2e/snapshot_tables/task_issue_assignees.csv
b/backend/plugins/zentao/e2e/snapshot_tables/task_issue_assignees.csv
index 33aa4b036..bdd00be19 100644
--- a/backend/plugins/zentao/e2e/snapshot_tables/task_issue_assignees.csv
+++ b/backend/plugins/zentao/e2e/snapshot_tables/task_issue_assignees.csv
@@ -1,4 +1,4 @@
issue_id,assignee_id,assignee_name
-zentao:ZentaoTask:1:1,zentao:ZentaoAccount:1,开发乙
-zentao:ZentaoTask:1:2,zentao:ZentaoAccount:1,开发乙
-zentao:ZentaoTask:1:3,zentao:ZentaoAccount:1,开发乙
+zentao:ZentaoTask:1:1,zentao:ZentaoAccount:1:5,开发乙
+zentao:ZentaoTask:1:2,zentao:ZentaoAccount:1:5,开发乙
+zentao:ZentaoTask:1:3,zentao:ZentaoAccount:1:5,开发乙
diff --git a/backend/plugins/zentao/tasks/bug_convertor.go
b/backend/plugins/zentao/tasks/bug_convertor.go
index 200742721..945e27351 100644
--- a/backend/plugins/zentao/tasks/bug_convertor.go
+++ b/backend/plugins/zentao/tasks/bug_convertor.go
@@ -80,10 +80,6 @@ func ConvertBugForOneProduct(taskCtx plugin.SubTaskContext)
errors.Error {
},
Convert: func(inputRow interface{}) ([]interface{},
errors.Error) {
toolEntity := inputRow.(*models.ZentaoBug)
- parentIssueId := ""
- if toolEntity.Story != 0 {
- parentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Story)
- }
domainEntity := &ticket.Issue{
DomainEntity: domainlayer.DomainEntity{
Id:
bugIdGen.Generate(toolEntity.ConnectionId, toolEntity.ID),
@@ -96,18 +92,23 @@ func ConvertBugForOneProduct(taskCtx plugin.SubTaskContext)
errors.Error {
ResolutionDate:
toolEntity.ClosedDate.ToNullableTime(),
CreatedDate:
toolEntity.OpenedDate.ToNullableTime(),
UpdatedDate:
toolEntity.LastEditedDate.ToNullableTime(),
- ParentIssueId: parentIssueId,
Priority: getPriority(toolEntity.Pri),
- CreatorId:
accountIdGen.Generate(toolEntity.ConnectionId, toolEntity.OpenedById),
CreatorName: toolEntity.OpenedByName,
- AssigneeId:
accountIdGen.Generate(toolEntity.ConnectionId, toolEntity.AssignedToId),
AssigneeName: toolEntity.AssignedToName,
Severity:
string(rune(toolEntity.Severity)),
Url: toolEntity.Url,
OriginalProject: getOriginalProject(data),
Status: toolEntity.StdStatus,
}
-
+ if toolEntity.Story != 0 {
+ domainEntity.ParentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Story)
+ }
+ if toolEntity.OpenedById != 0 {
+ domainEntity.CreatorId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.OpenedById)
+ }
+ if toolEntity.AssignedToId != 0 {
+ domainEntity.AssigneeId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.AssignedToId)
+ }
if toolEntity.ClosedDate != nil {
domainEntity.LeadTimeMinutes =
int64(toolEntity.ClosedDate.ToNullableTime().Sub(toolEntity.OpenedDate.ToTime()).Minutes())
}
diff --git a/backend/plugins/zentao/tasks/changelog_convertor.go
b/backend/plugins/zentao/tasks/changelog_convertor.go
index 90e8f0d39..6cd43730a 100644
--- a/backend/plugins/zentao/tasks/changelog_convertor.go
+++ b/backend/plugins/zentao/tasks/changelog_convertor.go
@@ -20,6 +20,7 @@ package tasks
import (
"fmt"
"reflect"
+ "strconv"
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
@@ -67,6 +68,9 @@ func ConvertChangelog(taskCtx plugin.SubTaskContext)
errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
db := taskCtx.GetDal()
changelogIdGen :=
didgen.NewDomainIdGenerator(&models.ZentaoChangelogDetail{})
+ accountIdGen := didgen.NewDomainIdGenerator(&models.ZentaoAccount{})
+ executionIdGen := didgen.NewDomainIdGenerator(&models.ZentaoExecution{})
+ cache := newAccountCache(db, data.Options.ConnectionId)
cn := models.ZentaoChangelog{}.TableName()
cdn := models.ZentaoChangelogDetail{}.TableName()
an := models.ZentaoAccount{}.TableName()
@@ -116,6 +120,38 @@ func ConvertChangelog(taskCtx plugin.SubTaskContext)
errors.Error {
ToValue: cl.New,
CreatedDate: cl.Date,
}
+ if domainCl.FieldName == "assignedTo" {
+ domainCl.FieldName = "assignee"
+ if cl.Old != "" {
+ if id := cache.getAccountID(cl.Old); id
!= 0 {
+ domainCl.OriginalFromValue =
accountIdGen.Generate(data.Options.ConnectionId, id)
+ domainCl.FromValue =
accountIdGen.Generate(data.Options.ConnectionId, id)
+ }
+ }
+ if cl.New != "" {
+ if id := cache.getAccountID(cl.New); id
!= 0 {
+ domainCl.OriginalToValue =
accountIdGen.Generate(data.Options.ConnectionId, id)
+ domainCl.ToValue =
accountIdGen.Generate(data.Options.ConnectionId, id)
+ }
+ }
+ }
+ if domainCl.FieldName == "execution" {
+ domainCl.FieldName = "Sprint"
+ if cl.Old != "" {
+ oldValue, _ := strconv.ParseInt(cl.Old,
10, 64)
+ if oldValue != 0 {
+ domainCl.OriginalFromValue =
executionIdGen.Generate(data.Options.ConnectionId, oldValue)
+ domainCl.FromValue =
executionIdGen.Generate(data.Options.ConnectionId, oldValue)
+ }
+ }
+ if cl.New != "" {
+ newValue, _ := strconv.ParseInt(cl.New,
10, 64)
+ if newValue != 0 {
+ domainCl.OriginalToValue =
executionIdGen.Generate(data.Options.ConnectionId, newValue)
+ domainCl.ToValue =
executionIdGen.Generate(data.Options.ConnectionId, newValue)
+ }
+ }
+ }
return []interface{}{
domainCl,
@@ -129,3 +165,30 @@ func ConvertChangelog(taskCtx plugin.SubTaskContext)
errors.Error {
return convertor.Execute()
}
+
+// accountCache is a cache for account id
+type accountCache struct {
+ accounts map[string]int64
+ db dal.Dal
+ connectionId uint64
+}
+
+func newAccountCache(db dal.Dal, connectionId uint64) *accountCache {
+ return &accountCache{db: db, connectionId: connectionId, accounts:
make(map[string]int64)}
+}
+
+func (a *accountCache) getAccountID(account string) int64 {
+ if id, ok := a.accounts[account]; ok {
+ return id
+ }
+ var zentaoAccount models.ZentaoAccount
+ err := a.db.First(
+ &zentaoAccount,
+ dal.Where("connection_id = ? AND account = ?", a.connectionId,
account),
+ )
+ if err != nil {
+ return 0
+ }
+ a.accounts[account] = zentaoAccount.ID
+ return zentaoAccount.ID
+}
diff --git a/backend/plugins/zentao/tasks/shared.go
b/backend/plugins/zentao/tasks/shared.go
index c303f4fe7..6f029ed09 100644
--- a/backend/plugins/zentao/tasks/shared.go
+++ b/backend/plugins/zentao/tasks/shared.go
@@ -184,7 +184,6 @@ func ignoreHTTPStatus404(res *http.Response) errors.Error {
func RangeProductOneByOne(taskCtx plugin.SubTaskContext, callback func(taskCtx
plugin.SubTaskContext) errors.Error) errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
-
for id, name := range data.ProductList {
data.Options.ProductId = id
data.ProductName = name
diff --git a/backend/plugins/zentao/tasks/story_convertor.go
b/backend/plugins/zentao/tasks/story_convertor.go
index 282941581..bd7eca35e 100644
--- a/backend/plugins/zentao/tasks/story_convertor.go
+++ b/backend/plugins/zentao/tasks/story_convertor.go
@@ -49,7 +49,6 @@ func ConvertStoryForOneProduct(taskCtx plugin.SubTaskContext)
errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
db := taskCtx.GetDal()
storyIdGen := didgen.NewDomainIdGenerator(&models.ZentaoStory{})
-
boardIdGen := didgen.NewDomainIdGenerator(&models.ZentaoProduct{})
accountIdGen := didgen.NewDomainIdGenerator(&models.ZentaoAccount{})
if data.Options.ProjectId != 0 {
@@ -79,35 +78,35 @@ func ConvertStoryForOneProduct(taskCtx
plugin.SubTaskContext) errors.Error {
},
Convert: func(inputRow interface{}) ([]interface{},
errors.Error) {
toolEntity := inputRow.(*models.ZentaoStory)
- parentIssueId := ""
- if toolEntity.Parent != 0 {
- parentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Parent)
- }
domainEntity := &ticket.Issue{
DomainEntity: domainlayer.DomainEntity{
Id:
storyIdGen.Generate(toolEntity.ConnectionId, toolEntity.ID),
},
- IssueKey:
strconv.FormatInt(toolEntity.ID, 10),
- Title: toolEntity.Title,
- Type: ticket.REQUIREMENT,
- OriginalType: toolEntity.Type + "."
+ toolEntity.Category,
- OriginalStatus: toolEntity.Status +
"-" + toolEntity.Stage,
- ResolutionDate:
toolEntity.ClosedDate.ToNullableTime(),
- CreatedDate:
toolEntity.OpenedDate.ToNullableTime(),
- UpdatedDate:
toolEntity.LastEditedDate.ToNullableTime(),
- ParentIssueId: parentIssueId,
- Priority:
getPriority(toolEntity.Pri),
- CreatorId:
accountIdGen.Generate(toolEntity.ConnectionId),
- CreatorName:
toolEntity.OpenedByName,
- AssigneeId:
accountIdGen.Generate(toolEntity.ConnectionId),
- AssigneeName:
toolEntity.AssignedToName,
- Url: toolEntity.Url,
- OriginalProject:
getOriginalProject(data),
- Status: toolEntity.StdStatus,
- OriginalEstimateMinutes:
int64(toolEntity.Estimate * 60),
+ IssueKey:
strconv.FormatInt(toolEntity.ID, 10),
+ Title: toolEntity.Title,
+ Type: ticket.REQUIREMENT,
+ OriginalType: toolEntity.Type + "." +
toolEntity.Category,
+ OriginalStatus: toolEntity.Status,
+ ResolutionDate:
toolEntity.ClosedDate.ToNullableTime(),
+ CreatedDate:
toolEntity.OpenedDate.ToNullableTime(),
+ UpdatedDate:
toolEntity.LastEditedDate.ToNullableTime(),
+ Priority: getPriority(toolEntity.Pri),
+ CreatorName: toolEntity.OpenedByName,
+ AssigneeName: toolEntity.AssignedToName,
+ Url: toolEntity.Url,
+ OriginalProject: getOriginalProject(data),
+ Status: toolEntity.StdStatus,
+ }
+ if toolEntity.Parent != 0 {
+ domainEntity.ParentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Parent)
+ }
+ if toolEntity.OpenedById != 0 {
+ domainEntity.CreatorId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.OpenedById)
+ }
+ if toolEntity.AssignedToId != 0 {
+ domainEntity.AssigneeId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.AssignedToId)
}
-
if domainEntity.OriginalStatus == "closed-closed" {
domainEntity.OriginalStatus = "closed"
}
diff --git a/backend/plugins/zentao/tasks/task_convertor.go
b/backend/plugins/zentao/tasks/task_convertor.go
index 04de474d7..7d39b7d2b 100644
--- a/backend/plugins/zentao/tasks/task_convertor.go
+++ b/backend/plugins/zentao/tasks/task_convertor.go
@@ -72,37 +72,36 @@ func ConvertTask(taskCtx plugin.SubTaskContext)
errors.Error {
},
Convert: func(inputRow interface{}) ([]interface{},
errors.Error) {
toolEntity := inputRow.(*models.ZentaoTask)
- parentIssueId := ""
- if toolEntity.Story != 0 {
- parentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Story)
- }
+
domainEntity := &ticket.Issue{
DomainEntity: domainlayer.DomainEntity{
Id:
taskIdGen.Generate(toolEntity.ConnectionId, toolEntity.ID),
},
- IssueKey:
strconv.FormatInt(toolEntity.ID, 10),
- Title: toolEntity.Name,
- Description: toolEntity.Description,
- Type: ticket.TASK,
- OriginalType: toolEntity.Type,
- OriginalStatus: toolEntity.Status,
- ResolutionDate:
toolEntity.ClosedDate.ToNullableTime(),
- CreatedDate:
toolEntity.OpenedDate.ToNullableTime(),
- UpdatedDate:
toolEntity.LastEditedDate.ToNullableTime(),
- ParentIssueId: parentIssueId,
- Priority:
getPriority(toolEntity.Pri),
- CreatorId:
accountIdGen.Generate(toolEntity.ConnectionId),
- CreatorName:
toolEntity.OpenedByName,
- AssigneeId:
accountIdGen.Generate(toolEntity.ConnectionId),
- AssigneeName:
toolEntity.AssignedToName,
- Url: toolEntity.Url,
- OriginalProject:
getOriginalProject(data),
- Status: toolEntity.StdStatus,
- OriginalEstimateMinutes:
int64(toolEntity.Estimate * 60),
- TimeSpentMinutes:
int64(toolEntity.Consumed * 60),
- LeadTimeMinutes: int64(toolEntity.Left
* 60),
+ IssueKey:
strconv.FormatInt(toolEntity.ID, 10),
+ Title: toolEntity.Name,
+ Description: toolEntity.Description,
+ Type: ticket.TASK,
+ OriginalType: toolEntity.Type + "." +
toolEntity.Mode,
+ OriginalStatus: toolEntity.Status,
+ ResolutionDate:
toolEntity.ClosedDate.ToNullableTime(),
+ CreatedDate:
toolEntity.OpenedDate.ToNullableTime(),
+ UpdatedDate:
toolEntity.LastEditedDate.ToNullableTime(),
+ Priority: getPriority(toolEntity.Pri),
+ CreatorName: toolEntity.OpenedByName,
+ AssigneeName: toolEntity.AssignedToName,
+ Url: toolEntity.Url,
+ OriginalProject: getOriginalProject(data),
+ Status: toolEntity.StdStatus,
+ }
+ if toolEntity.Parent != 0 {
+ domainEntity.ParentIssueId =
storyIdGen.Generate(data.Options.ConnectionId, toolEntity.Parent)
+ }
+ if toolEntity.OpenedById != 0 {
+ domainEntity.CreatorId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.OpenedById)
+ }
+ if toolEntity.AssignedToId != 0 {
+ domainEntity.AssigneeId =
accountIdGen.Generate(data.Options.ConnectionId, toolEntity.AssignedToId)
}
-
if toolEntity.ClosedDate != nil {
domainEntity.LeadTimeMinutes =
int64(toolEntity.ClosedDate.ToNullableTime().Sub(toolEntity.OpenedDate.ToTime()).Minutes())
}
@@ -139,7 +138,7 @@ func ConvertTask(taskCtx plugin.SubTaskContext)
errors.Error {
if toolEntity.FromBug != 0 {
sprintIssueBug := &ticket.SprintIssue{
SprintId: sprintId,
- IssueId:
bugIdGen.Generate(data.Options.ConnectionId, toolEntity.FromBug),
+ IssueId:
bugIdGen.Generate(data.Options.ConnectionId, int64(toolEntity.FromBug)),
}
results = append(results, sprintIssueBug)
}