You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/08/23 09:58:16 UTC
[incubator-devlake] branch main updated: fix(zentao): remove execution's product stories (#5942)
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 7ee708a59 fix(zentao): remove execution's product stories (#5942)
7ee708a59 is described below
commit 7ee708a5914659d4c49f4f568c4ef490e64b139d
Author: Lynwee <li...@merico.dev>
AuthorDate: Wed Aug 23 17:58:10 2023 +0800
fix(zentao): remove execution's product stories (#5942)
---
backend/helpers/pluginhelper/api/api_collector.go | 10 +++---
backend/helpers/pluginhelper/api/data_convertor.go | 2 +-
.../plugins/zentao/tasks/department_convertor.go | 1 -
backend/plugins/zentao/tasks/iterator.go | 4 ++-
backend/plugins/zentao/tasks/project_convertor.go | 2 --
backend/plugins/zentao/tasks/story_collector.go | 42 +++++++++++-----------
6 files changed, 29 insertions(+), 32 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/api_collector.go b/backend/helpers/pluginhelper/api/api_collector.go
index 26ebe2118..0cd4b1c4d 100644
--- a/backend/helpers/pluginhelper/api/api_collector.go
+++ b/backend/helpers/pluginhelper/api/api_collector.go
@@ -21,6 +21,7 @@ import (
"bytes"
"encoding/json"
"fmt"
+ "github.com/apache/incubator-devlake/core/plugin"
"io"
"net/http"
"net/url"
@@ -30,10 +31,11 @@ import (
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/common"
)
+var _ plugin.SubTask = (*ApiCollector)(nil)
+
// Pager contains pagination information for a api request
type Pager struct {
Page int
@@ -241,7 +243,7 @@ func (collector *ApiCollector) exec(input interface{}) {
Page: 1,
Size: collector.args.PageSize,
}
- // featch the detail
+ // fetch the detail
if collector.args.PageSize <= 0 {
collector.fetchAsync(reqData, nil)
// fetch pages sequentially
@@ -324,7 +326,7 @@ func (collector *ApiCollector) fetchPagesUndetermined(reqData *RequestData) {
concurrency := collector.args.Concurrency
if concurrency == 0 {
// normally when a multi-pages api depends on a another resource, like jira changelogs depend on issue ids
- // it tend to have less page, like 1 or 2 pages in total
+ // it tends to have less page, like 1 or 2 pages in total
if collector.args.Input != nil {
concurrency = 2
} else {
@@ -484,5 +486,3 @@ func (collector *ApiCollector) fetchAsync(reqData *RequestData, handler func(int
}
logger.Debug("fetchAsync === enqueued for %s %v", apiUrl, apiQuery)
}
-
-var _ plugin.SubTask = (*ApiCollector)(nil)
diff --git a/backend/helpers/pluginhelper/api/data_convertor.go b/backend/helpers/pluginhelper/api/data_convertor.go
index dcefd8293..faf88ec6e 100644
--- a/backend/helpers/pluginhelper/api/data_convertor.go
+++ b/backend/helpers/pluginhelper/api/data_convertor.go
@@ -38,7 +38,7 @@ type DataConvertHandler func(row interface{}) ([]interface{}, errors.Error)
// BatchSize: batch size
type DataConverterArgs struct {
RawDataSubTaskArgs
- // Domain layer entity Id prefix, i.e. `jira:JiraIssue:1`, `github:GithubIssue`
+ // Domain layer entity ID prefix, i.e. `jira:JiraIssue:1`, `github:GithubIssue`
InputRowType reflect.Type
Input dal.Rows
Convert DataConvertHandler
diff --git a/backend/plugins/zentao/tasks/department_convertor.go b/backend/plugins/zentao/tasks/department_convertor.go
index b2c4a7020..ce3dcf66e 100644
--- a/backend/plugins/zentao/tasks/department_convertor.go
+++ b/backend/plugins/zentao/tasks/department_convertor.go
@@ -62,7 +62,6 @@ func ConvertDepartment(taskCtx plugin.SubTaskContext) errors.Error {
},
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
toolEntity := inputRow.(*models.ZentaoDepartment)
-
domainEntity := &crossdomain.Team{
DomainEntity: domainlayer.DomainEntity{
Id: departmentIdGen.Generate(toolEntity.ConnectionId, toolEntity.ID),
diff --git a/backend/plugins/zentao/tasks/iterator.go b/backend/plugins/zentao/tasks/iterator.go
index 0c3400a72..b55bfd525 100644
--- a/backend/plugins/zentao/tasks/iterator.go
+++ b/backend/plugins/zentao/tasks/iterator.go
@@ -28,7 +28,9 @@ type iteratorConcator struct {
}
func newIteratorConcator(iterators ...api.Iterator) *iteratorConcator {
- return &iteratorConcator{iterators: iterators}
+ return &iteratorConcator{
+ iterators: iterators,
+ }
}
func (w *iteratorConcator) HasNext() bool {
diff --git a/backend/plugins/zentao/tasks/project_convertor.go b/backend/plugins/zentao/tasks/project_convertor.go
index 7beb16d5e..3f217a963 100644
--- a/backend/plugins/zentao/tasks/project_convertor.go
+++ b/backend/plugins/zentao/tasks/project_convertor.go
@@ -65,9 +65,7 @@ func ConvertProjects(taskCtx plugin.SubTaskContext) errors.Error {
},
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
toolProject := inputRow.(*models.ZentaoProject)
-
data.ProjectName = toolProject.Name
-
domainBoard := &ticket.Board{
DomainEntity: domainlayer.DomainEntity{
Id: boardIdGen.Generate(toolProject.ConnectionId, toolProject.Id),
diff --git a/backend/plugins/zentao/tasks/story_collector.go b/backend/plugins/zentao/tasks/story_collector.go
index 2eaa6afbc..40b077ae4 100644
--- a/backend/plugins/zentao/tasks/story_collector.go
+++ b/backend/plugins/zentao/tasks/story_collector.go
@@ -32,6 +32,14 @@ const RAW_STORY_TABLE = "zentao_api_stories"
var _ plugin.SubTaskEntryPoint = CollectStory
+var CollectStoryMeta = plugin.SubTaskMeta{
+ Name: "collectStory",
+ EntryPoint: CollectStory,
+ EnabledByDefault: true,
+ Description: "Collect Story data from Zentao api",
+ DomainTypes: []string{plugin.DOMAIN_TYPE_TICKET},
+}
+
type storyInput struct {
Path string
ProjectId int64
@@ -42,16 +50,11 @@ type storyInput struct {
func CollectStory(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
// project iterator
- iter0 := newIteratorFromSlice([]interface{}{&storyInput{ProjectId: data.Options.ProjectId, Path: fmt.Sprintf("/projects/%d", data.Options.ProjectId)}})
-
- // product iterator
- productCursor, productIterator, err := getProductIterator(taskCtx)
- if err != nil {
- return err
- }
- defer productCursor.Close()
- iter1 := newIteratorWrapper(productIterator, func(arg interface{}) interface{} {
- return &storyInput{ProductId: arg.(*input).Id, Path: fmt.Sprintf("/products/%d", arg.(*input).Id)}
+ projectStoryIter := newIteratorFromSlice([]interface{}{
+ &storyInput{
+ ProjectId: data.Options.ProjectId,
+ Path: fmt.Sprintf("/projects/%d", data.Options.ProjectId),
+ },
})
// execution iterator
@@ -60,8 +63,11 @@ func CollectStory(taskCtx plugin.SubTaskContext) errors.Error {
return err
}
defer executionCursor.Close()
- iter2 := newIteratorWrapper(executionIterator, func(arg interface{}) interface{} {
- return &storyInput{ExecutionId: arg.(*input).Id, Path: fmt.Sprintf("/executions/%d", arg.(*input).Id)}
+ executionStoryIter := newIteratorWrapper(executionIterator, func(arg interface{}) interface{} {
+ return &storyInput{
+ ExecutionId: arg.(*input).Id,
+ Path: fmt.Sprintf("/executions/%d", arg.(*input).Id),
+ }
})
collector, err := api.NewApiCollector(api.ApiCollectorArgs{
@@ -70,7 +76,7 @@ func CollectStory(taskCtx plugin.SubTaskContext) errors.Error {
Options: data.Options,
Table: RAW_STORY_TABLE,
},
- Input: newIteratorConcator(iter0, iter1, iter2),
+ Input: newIteratorConcator(projectStoryIter, executionStoryIter),
ApiClient: data.ApiClient,
PageSize: 100,
UrlTemplate: "{{ .Input.Path }}/stories",
@@ -91,7 +97,7 @@ func CollectStory(taskCtx plugin.SubTaskContext) errors.Error {
return nil, nil
}
if err != nil {
- return nil, errors.Default.Wrap(err, "error reading endpoint response by Zentao bug collector")
+ return nil, errors.Default.Wrap(err, "error reading endpoint response by Zentao story collector")
}
return data.Story, nil
},
@@ -102,11 +108,3 @@ func CollectStory(taskCtx plugin.SubTaskContext) errors.Error {
return collector.Execute()
}
-
-var CollectStoryMeta = plugin.SubTaskMeta{
- Name: "collectStory",
- EntryPoint: CollectStory,
- EnabledByDefault: true,
- Description: "Collect Story data from Zentao api",
- DomainTypes: []string{plugin.DOMAIN_TYPE_TICKET},
-}