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

warren pushed a commit to branch feat-plugin-zentao
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/feat-plugin-zentao by this 
push:
     new feab0162 feat:add zentao task & fix:update stories -> story (#3617)
feab0162 is described below

commit feab0162694da755a6b5a88f46f06f94155f4bed
Author: txtw <[email protected]>
AuthorDate: Sun Oct 30 19:14:58 2022 +0800

    feat:add zentao task & fix:update stories -> story (#3617)
---
 plugins/zentao/impl/impl.go                        |   9 +-
 .../models/archived/{stories.go => story.go}       |  12 +--
 plugins/zentao/models/archived/task.go             | 105 +++++++++++++++++++++
 .../migrationscripts/20220906_add_init_tables.go   |   3 +-
 plugins/zentao/models/{stories.go => story.go}     |  12 +--
 plugins/zentao/models/task.go                      | 105 +++++++++++++++++++++
 plugins/zentao/tasks/bug_convertor.go              |   4 +-
 .../{stories_collector.go => story_collector.go}   |  20 ++--
 .../{stories_convertor.go => story_convertor.go}   |  44 ++++-----
 .../{stories_extractor.go => story_extractor.go}   |  24 ++---
 .../{stories_collector.go => task_collector.go}    |  24 ++---
 .../{stories_convertor.go => task_convertor.go}    |  59 ++++++------
 .../{stories_extractor.go => task_extractor.go}    |  24 ++---
 13 files changed, 329 insertions(+), 116 deletions(-)

diff --git a/plugins/zentao/impl/impl.go b/plugins/zentao/impl/impl.go
index 0289b614..98e200a8 100644
--- a/plugins/zentao/impl/impl.go
+++ b/plugins/zentao/impl/impl.go
@@ -58,12 +58,15 @@ func (plugin Zentao) SubTaskMetas() []core.SubTaskMeta {
                tasks.CollectExecutionMeta,
                tasks.ExtractExecutionsMeta,
                tasks.ConvertExecutionsMeta,
-               tasks.CollectStoriesMeta,
-               tasks.ExtractStoriesMeta,
-               tasks.ConvertStoriesMeta,
+               tasks.CollectStoryMeta,
+               tasks.ExtractStoryMeta,
+               tasks.ConvertStoryMeta,
                tasks.CollectBugMeta,
                tasks.ExtractBugMeta,
                tasks.ConvertBugMeta,
+               tasks.CollectTaskMeta,
+               tasks.ExtractTaskMeta,
+               tasks.ConvertTaskMeta,
        }
 }
 
diff --git a/plugins/zentao/models/archived/stories.go 
b/plugins/zentao/models/archived/story.go
similarity index 94%
rename from plugins/zentao/models/archived/stories.go
rename to plugins/zentao/models/archived/story.go
index d197e1fd..48a64bef 100644
--- a/plugins/zentao/models/archived/stories.go
+++ b/plugins/zentao/models/archived/story.go
@@ -22,7 +22,7 @@ import (
        "github.com/apache/incubator-devlake/plugins/helper"
 )
 
-type ZentaoStories struct {
+type ZentaoStory struct {
        archived.NoPKModel
        ConnectionId uint64 `gorm:"primaryKey;type:BIGINT  NOT NULL"`
        ExecutionId  uint64 `json:"execution_id"`
@@ -88,12 +88,12 @@ type ZentaoStories struct {
 }
 
 type AssignedTo struct {
-       ID       int    `json:"id"`
-       Account  string `json:"account"`
-       Avatar   string `json:"avatar"`
-       Realname string `json:"realname"`
+       AssignedToID       int    `json:"id"`
+       AssignedToAccount  string `json:"account"`
+       AssignedToAvatar   string `json:"avatar"`
+       AssignedToRealname string `json:"realname"`
 }
 
-func (ZentaoStories) TableName() string {
+func (ZentaoStory) TableName() string {
        return "_tool_zentao_stories"
 }
diff --git a/plugins/zentao/models/archived/task.go 
b/plugins/zentao/models/archived/task.go
new file mode 100644
index 00000000..1fff6542
--- /dev/null
+++ b/plugins/zentao/models/archived/task.go
@@ -0,0 +1,105 @@
+/*
+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 archived
+
+import (
+       "github.com/apache/incubator-devlake/models/migrationscripts/archived"
+       "github.com/apache/incubator-devlake/plugins/helper"
+)
+
+type ZentaoTask struct {
+       archived.NoPKModel
+       ConnectionId  uint64 `gorm:"primaryKey;type:BIGINT  NOT NULL"`
+       ExecutionId   uint64 `json:"execution_id"`
+       ID            int    `json:"id" gorm:"primaryKey;type:BIGINT  NOT NULL"`
+       Project       int    `json:"project"`
+       Parent        int    `json:"parent"`
+       Execution     int    `json:"execution"`
+       Module        int    `json:"module"`
+       Design        int    `json:"design"`
+       Story         int    `json:"story"`
+       StoryVersion  int    `json:"storyVersion"`
+       DesignVersion int    `json:"designVersion"`
+       FromBug       int    `json:"fromBug"`
+       Feedback      int    `json:"feedback"`
+       FromIssue     int    `json:"fromIssue"`
+       Name          string `json:"name"`
+       Type          string `json:"type"`
+       Mode          string `json:"mode"`
+       Pri           int    `json:"pri"`
+       Estimate      int    `json:"estimate"`
+       Consumed      int    `json:"consumed"`
+       Left          int    `json:"left"`
+       Deadline      string `json:"deadline"`
+       Status        string `json:"status"`
+       SubStatus     string `json:"subStatus"`
+       Color         string `json:"color"`
+       //Mailto        interface{} `json:"mailto"`
+       Desc               string `json:"desc"`
+       Version            int    `json:"version"`
+       OpenedBy           `json:"openedBy"`
+       OpenedDate         *helper.Iso8601Time `json:"openedDate"`
+       AssignedTo         `json:"assignedTo"`
+       AssignedDate       *helper.Iso8601Time `json:"assignedDate"`
+       EstStarted         string              `json:"estStarted"`
+       RealStarted        *helper.Iso8601Time `json:"realStarted"`
+       FinishedBy         `json:"finishedBy"`
+       FinishedDate       *helper.Iso8601Time `json:"finishedDate"`
+       FinishedList       string              `json:"finishedList"`
+       CanceledBy         `json:"canceledBy"`
+       CanceledDate       *helper.Iso8601Time `json:"canceledDate"`
+       ClosedBy           *helper.Iso8601Time `json:"closedBy"`
+       ClosedDate         *helper.Iso8601Time `json:"closedDate"`
+       PlanDuration       int                 `json:"planDuration"`
+       RealDuration       int                 `json:"realDuration"`
+       ClosedReason       string              `json:"closedReason"`
+       LastEditedBy       `json:"lastEditedBy"`
+       LastEditedDate     *helper.Iso8601Time `json:"lastEditedDate"`
+       ActivatedDate      string              `json:"activatedDate"`
+       Order              int                 `json:"order"`
+       Repo               int                 `json:"repo"`
+       Mr                 int                 `json:"mr"`
+       Entry              string              `json:"entry"`
+       Lines              string              `json:"lines"`
+       V1                 string              `json:"v1"`
+       V2                 string              `json:"v2"`
+       Deleted            bool                `json:"deleted"`
+       Vision             string              `json:"vision"`
+       StoryID            int                 `json:"storyID"`
+       StoryTitle         string              `json:"storyTitle"`
+       Product            int                 `json:"product"`
+       Branch             int                 `json:"branch"`
+       LatestStoryVersion int                 `json:"latestStoryVersion"`
+       StoryStatus        string              `json:"storyStatus"`
+       AssignedToRealName string              `json:"assignedToRealName"`
+       PriOrder           string              `json:"priOrder"`
+       NeedConfirm        bool                `json:"needConfirm"`
+       ProductType        string              `json:"productType"`
+       Progress           int                 `json:"progress"`
+}
+
+type FinishedBy struct {
+       FinishedByID       int    `json:"id"`
+       FinishedByAccount  string `json:"account"`
+       FinishedByAvatar   string `json:"avatar"`
+       FinishedByRealname string `json:"realname"`
+}
+
+func (ZentaoTask) TableName() string {
+       return "_tool_zentao_tasks"
+}
diff --git a/plugins/zentao/models/migrationscripts/20220906_add_init_tables.go 
b/plugins/zentao/models/migrationscripts/20220906_add_init_tables.go
index 41fc8d94..9d779b61 100644
--- a/plugins/zentao/models/migrationscripts/20220906_add_init_tables.go
+++ b/plugins/zentao/models/migrationscripts/20220906_add_init_tables.go
@@ -31,8 +31,9 @@ func (u *addInitTables) Up(ctx context.Context, db *gorm.DB) 
errors.Error {
                archived.ZentaoConnection{},
                archived.ZentaoProject{},
                archived.ZentaoExecution{},
-               archived.ZentaoStories{},
+               archived.ZentaoStory{},
                archived.ZentaoBug{},
+               archived.ZentaoTask{},
        ))
 }
 
diff --git a/plugins/zentao/models/stories.go b/plugins/zentao/models/story.go
similarity index 94%
rename from plugins/zentao/models/stories.go
rename to plugins/zentao/models/story.go
index 1d65c111..9cdb3c63 100644
--- a/plugins/zentao/models/stories.go
+++ b/plugins/zentao/models/story.go
@@ -22,7 +22,7 @@ import (
        "github.com/apache/incubator-devlake/plugins/helper"
 )
 
-type ZentaoStories struct {
+type ZentaoStory struct {
        common.NoPKModel
        ConnectionId uint64 `gorm:"primaryKey;type:BIGINT  NOT NULL"`
        ExecutionId  uint64 `json:"execution_id"`
@@ -88,12 +88,12 @@ type ZentaoStories struct {
 }
 
 type AssignedTo struct {
-       ID       int    `json:"id"`
-       Account  string `json:"account"`
-       Avatar   string `json:"avatar"`
-       Realname string `json:"realname"`
+       AssignedToID       int    `json:"id"`
+       AssignedToAccount  string `json:"account"`
+       AssignedToAvatar   string `json:"avatar"`
+       AssignedToRealname string `json:"realname"`
 }
 
-func (ZentaoStories) TableName() string {
+func (ZentaoStory) TableName() string {
        return "_tool_zentao_stories"
 }
diff --git a/plugins/zentao/models/task.go b/plugins/zentao/models/task.go
new file mode 100644
index 00000000..094ce0de
--- /dev/null
+++ b/plugins/zentao/models/task.go
@@ -0,0 +1,105 @@
+/*
+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 models
+
+import (
+       "github.com/apache/incubator-devlake/models/common"
+       "github.com/apache/incubator-devlake/plugins/helper"
+)
+
+type ZentaoTask struct {
+       common.NoPKModel
+       ConnectionId  uint64 `gorm:"primaryKey;type:BIGINT  NOT NULL"`
+       ExecutionId   uint64 `json:"execution_id"`
+       ID            int    `json:"id" gorm:"primaryKey;type:BIGINT  NOT NULL"`
+       Project       int    `json:"project"`
+       Parent        int    `json:"parent"`
+       Execution     int    `json:"execution"`
+       Module        int    `json:"module"`
+       Design        int    `json:"design"`
+       Story         int    `json:"story"`
+       StoryVersion  int    `json:"storyVersion"`
+       DesignVersion int    `json:"designVersion"`
+       FromBug       int    `json:"fromBug"`
+       Feedback      int    `json:"feedback"`
+       FromIssue     int    `json:"fromIssue"`
+       Name          string `json:"name"`
+       Type          string `json:"type"`
+       Mode          string `json:"mode"`
+       Pri           int    `json:"pri"`
+       Estimate      int    `json:"estimate"`
+       Consumed      int    `json:"consumed"`
+       Left          int    `json:"left"`
+       Deadline      string `json:"deadline"`
+       Status        string `json:"status"`
+       SubStatus     string `json:"subStatus"`
+       Color         string `json:"color"`
+       //Mailto        interface{} `json:"mailto"`
+       Desc               string `json:"desc"`
+       Version            int    `json:"version"`
+       OpenedBy           `json:"openedBy"`
+       OpenedDate         *helper.Iso8601Time `json:"openedDate"`
+       AssignedTo         `json:"assignedTo"`
+       AssignedDate       *helper.Iso8601Time `json:"assignedDate"`
+       EstStarted         string              `json:"estStarted"`
+       RealStarted        *helper.Iso8601Time `json:"realStarted"`
+       FinishedBy         `json:"finishedBy"`
+       FinishedDate       *helper.Iso8601Time `json:"finishedDate"`
+       FinishedList       string              `json:"finishedList"`
+       CanceledBy         `json:"canceledBy"`
+       CanceledDate       *helper.Iso8601Time `json:"canceledDate"`
+       ClosedBy           *helper.Iso8601Time `json:"closedBy"`
+       ClosedDate         *helper.Iso8601Time `json:"closedDate"`
+       PlanDuration       int                 `json:"planDuration"`
+       RealDuration       int                 `json:"realDuration"`
+       ClosedReason       string              `json:"closedReason"`
+       LastEditedBy       `json:"lastEditedBy"`
+       LastEditedDate     *helper.Iso8601Time `json:"lastEditedDate"`
+       ActivatedDate      string              `json:"activatedDate"`
+       Order              int                 `json:"order"`
+       Repo               int                 `json:"repo"`
+       Mr                 int                 `json:"mr"`
+       Entry              string              `json:"entry"`
+       Lines              string              `json:"lines"`
+       V1                 string              `json:"v1"`
+       V2                 string              `json:"v2"`
+       Deleted            bool                `json:"deleted"`
+       Vision             string              `json:"vision"`
+       StoryID            int                 `json:"storyID"`
+       StoryTitle         string              `json:"storyTitle"`
+       Product            int                 `json:"product"`
+       Branch             int                 `json:"branch"`
+       LatestStoryVersion int                 `json:"latestStoryVersion"`
+       StoryStatus        string              `json:"storyStatus"`
+       AssignedToRealName string              `json:"assignedToRealName"`
+       PriOrder           string              `json:"priOrder"`
+       NeedConfirm        bool                `json:"needConfirm"`
+       ProductType        string              `json:"productType"`
+       Progress           int                 `json:"progress"`
+}
+
+type FinishedBy struct {
+       FinishedByID       int    `json:"id"`
+       FinishedByAccount  string `json:"account"`
+       FinishedByAvatar   string `json:"avatar"`
+       FinishedByRealname string `json:"realname"`
+}
+
+func (ZentaoTask) TableName() string {
+       return "_tool_zentao_tasks"
+}
diff --git a/plugins/zentao/tasks/bug_convertor.go 
b/plugins/zentao/tasks/bug_convertor.go
index 397ff9be..4f179efd 100644
--- a/plugins/zentao/tasks/bug_convertor.go
+++ b/plugins/zentao/tasks/bug_convertor.go
@@ -91,8 +91,8 @@ func ConvertBug(taskCtx core.SubTaskContext) errors.Error {
                                TimeRemainingMinutes:    0,
                                CreatorId:               
string(toolBug.OpenedBy.OpenedByID),
                                CreatorName:             
toolBug.OpenedBy.OpenedByRealname,
-                               AssigneeId:              
string(toolBug.AssignedTo.ID),
-                               AssigneeName:            
toolBug.AssignedTo.Realname,
+                               AssigneeId:              
string(toolBug.AssignedTo.AssignedToID),
+                               AssigneeName:            
toolBug.AssignedTo.AssignedToRealname,
                                Severity:                
string(toolBug.Severity),
                                Component:               "",
                                DeploymentId:            "",
diff --git a/plugins/zentao/tasks/stories_collector.go 
b/plugins/zentao/tasks/story_collector.go
similarity index 83%
copy from plugins/zentao/tasks/stories_collector.go
copy to plugins/zentao/tasks/story_collector.go
index 9c85cc53..603b89fd 100644
--- a/plugins/zentao/tasks/stories_collector.go
+++ b/plugins/zentao/tasks/story_collector.go
@@ -28,11 +28,11 @@ import (
        "net/url"
 )
 
-const RAW_STORIES_TABLE = "zentao_stories"
+const RAW_STORY_TABLE = "zentao_stories"
 
-var _ core.SubTaskEntryPoint = CollectStories
+var _ core.SubTaskEntryPoint = CollectStory
 
-func CollectStories(taskCtx core.SubTaskContext) errors.Error {
+func CollectStory(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
@@ -42,7 +42,7 @@ func CollectStories(taskCtx core.SubTaskContext) errors.Error 
{
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_STORY_TABLE,
                },
                ApiClient:   data.ApiClient,
                Incremental: false,
@@ -58,7 +58,7 @@ func CollectStories(taskCtx core.SubTaskContext) errors.Error 
{
                GetTotalPages: GetTotalPagesFromResponse,
                ResponseParser: func(res *http.Response) ([]json.RawMessage, 
errors.Error) {
                        var data struct {
-                               Stories []json.RawMessage `json:"stories"`
+                               Story []json.RawMessage `json:"stories"`
                        }
                        body, err := io.ReadAll(res.Body)
                        err = json.Unmarshal(body, &data)
@@ -66,7 +66,7 @@ func CollectStories(taskCtx core.SubTaskContext) errors.Error 
{
                        if err != nil {
                                return nil, errors.Default.Wrap(err, "error 
reading endpoint response by Zentao story collector")
                        }
-                       return data.Stories, nil
+                       return data.Story, nil
                },
        })
        if err != nil {
@@ -76,9 +76,9 @@ func CollectStories(taskCtx core.SubTaskContext) errors.Error 
{
        return collector.Execute()
 }
 
-var CollectStoriesMeta = core.SubTaskMeta{
-       Name:             "CollectStories",
-       EntryPoint:       CollectStories,
+var CollectStoryMeta = core.SubTaskMeta{
+       Name:             "CollectStory",
+       EntryPoint:       CollectStory,
        EnabledByDefault: true,
-       Description:      "Collect Stories data from Zentao api",
+       Description:      "Collect Story data from Zentao api",
 }
diff --git a/plugins/zentao/tasks/stories_convertor.go 
b/plugins/zentao/tasks/story_convertor.go
similarity index 70%
copy from plugins/zentao/tasks/stories_convertor.go
copy to plugins/zentao/tasks/story_convertor.go
index 4b6c160b..867c08a6 100644
--- a/plugins/zentao/tasks/stories_convertor.go
+++ b/plugins/zentao/tasks/story_convertor.go
@@ -29,22 +29,22 @@ import (
        "reflect"
 )
 
-var _ core.SubTaskEntryPoint = ConvertStories
+var _ core.SubTaskEntryPoint = ConvertStory
 
-var ConvertStoriesMeta = core.SubTaskMeta{
-       Name:             "convertStories",
-       EntryPoint:       ConvertStories,
+var ConvertStoryMeta = core.SubTaskMeta{
+       Name:             "convertStory",
+       EntryPoint:       ConvertStory,
        EnabledByDefault: true,
-       Description:      "convert Zentao stories",
+       Description:      "convert Zentao story",
        DomainTypes:      []string{core.DOMAIN_TYPE_TICKET},
 }
 
-func ConvertStories(taskCtx core.SubTaskContext) errors.Error {
+func ConvertStory(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        db := taskCtx.GetDal()
-       boardIdGen := didgen.NewDomainIdGenerator(&models.ZentaoStories{})
+       boardIdGen := didgen.NewDomainIdGenerator(&models.ZentaoStory{})
        cursor, err := db.Cursor(
-               dal.From(&models.ZentaoStories{}),
+               dal.From(&models.ZentaoStory{}),
                dal.Where(`_tool_zentao_stories.execution_id = ? and 
                        _tool_zentao_stories.connection_id = ?`, 
data.Options.ExecutionId, data.Options.ConnectionId),
        )
@@ -53,7 +53,7 @@ func ConvertStories(taskCtx core.SubTaskContext) errors.Error 
{
        }
        defer cursor.Close()
        convertor, err := helper.NewDataConverter(helper.DataConverterArgs{
-               InputRowType: reflect.TypeOf(models.ZentaoStories{}),
+               InputRowType: reflect.TypeOf(models.ZentaoStory{}),
                Input:        cursor,
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
                        Ctx: taskCtx,
@@ -62,38 +62,38 @@ func ConvertStories(taskCtx core.SubTaskContext) 
errors.Error {
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_STORY_TABLE,
                },
                Convert: func(inputRow interface{}) ([]interface{}, 
errors.Error) {
-                       toolStories := inputRow.(*models.ZentaoStories)
+                       toolStory := inputRow.(*models.ZentaoStory)
 
                        domainBoard := &ticket.Issue{
                                DomainEntity: domainlayer.DomainEntity{
-                                       Id: 
boardIdGen.Generate(toolStories.ConnectionId, toolStories.ID),
+                                       Id: 
boardIdGen.Generate(toolStory.ConnectionId, toolStory.ID),
                                },
                                Url:      "",
                                IconURL:  "",
                                IssueKey: "",
-                               Title:    toolStories.Title,
-                               //Description:             toolStories.Spec,
+                               Title:    toolStory.Title,
+                               //Description:             toolStory.Spec,
                                EpicKey:                 "",
-                               Type:                    toolStories.Type,
-                               Status:                  toolStories.Status,
+                               Type:                    toolStory.Type,
+                               Status:                  toolStory.Status,
                                OriginalStatus:          "",
                                StoryPoint:              0,
                                ResolutionDate:          nil,
-                               CreatedDate:             
toolStories.OpenedDate.ToNullableTime(),
-                               UpdatedDate:             
toolStories.LastEditedDate.ToNullableTime(),
+                               CreatedDate:             
toolStory.OpenedDate.ToNullableTime(),
+                               UpdatedDate:             
toolStory.LastEditedDate.ToNullableTime(),
                                LeadTimeMinutes:         0,
                                ParentIssueId:           "",
                                Priority:                "",
                                OriginalEstimateMinutes: 0,
                                TimeSpentMinutes:        0,
                                TimeRemainingMinutes:    0,
-                               CreatorId:               "",
-                               CreatorName:             
toolStories.OpenedBy.OpenedByRealname,
-                               AssigneeId:              "",
-                               AssigneeName:            
toolStories.AssignedTo.Realname,
+                               CreatorId:               
string(toolStory.OpenedBy.OpenedByID),
+                               CreatorName:             
toolStory.OpenedBy.OpenedByRealname,
+                               AssigneeId:              
string(toolStory.AssignedTo.AssignedToID),
+                               AssigneeName:            
toolStory.AssignedTo.AssignedToRealname,
                                Severity:                "",
                                Component:               "",
                                DeploymentId:            "",
diff --git a/plugins/zentao/tasks/stories_extractor.go 
b/plugins/zentao/tasks/story_extractor.go
similarity index 76%
copy from plugins/zentao/tasks/stories_extractor.go
copy to plugins/zentao/tasks/story_extractor.go
index 5c2bc3cf..ae07abc1 100644
--- a/plugins/zentao/tasks/stories_extractor.go
+++ b/plugins/zentao/tasks/story_extractor.go
@@ -25,17 +25,17 @@ import (
        "github.com/apache/incubator-devlake/plugins/zentao/models"
 )
 
-var _ core.SubTaskEntryPoint = ExtractStories
+var _ core.SubTaskEntryPoint = ExtractStory
 
-var ExtractStoriesMeta = core.SubTaskMeta{
-       Name:             "extractStories",
-       EntryPoint:       ExtractStories,
+var ExtractStoryMeta = core.SubTaskMeta{
+       Name:             "extractStory",
+       EntryPoint:       ExtractStory,
        EnabledByDefault: true,
-       Description:      "extract Zentao stories",
+       Description:      "extract Zentao story",
        DomainTypes:      []string{core.DOMAIN_TYPE_TICKET},
 }
 
-func ExtractStories(taskCtx core.SubTaskContext) errors.Error {
+func ExtractStory(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
@@ -45,18 +45,18 @@ func ExtractStories(taskCtx core.SubTaskContext) 
errors.Error {
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_STORY_TABLE,
                },
                Extract: func(row *helper.RawData) ([]interface{}, 
errors.Error) {
-                       stories := &models.ZentaoStories{}
-                       err := json.Unmarshal(row.Data, stories)
+                       story := &models.ZentaoStory{}
+                       err := json.Unmarshal(row.Data, story)
                        if err != nil {
                                return nil, errors.Default.WrapRaw(err)
                        }
-                       stories.ConnectionId = data.Options.ConnectionId
-                       stories.ExecutionId = data.Options.ExecutionId
+                       story.ConnectionId = data.Options.ConnectionId
+                       story.ExecutionId = data.Options.ExecutionId
                        results := make([]interface{}, 0)
-                       results = append(results, stories)
+                       results = append(results, story)
                        return results, nil
                },
        })
diff --git a/plugins/zentao/tasks/stories_collector.go 
b/plugins/zentao/tasks/task_collector.go
similarity index 80%
rename from plugins/zentao/tasks/stories_collector.go
rename to plugins/zentao/tasks/task_collector.go
index 9c85cc53..8c082d6d 100644
--- a/plugins/zentao/tasks/stories_collector.go
+++ b/plugins/zentao/tasks/task_collector.go
@@ -28,11 +28,11 @@ import (
        "net/url"
 )
 
-const RAW_STORIES_TABLE = "zentao_stories"
+const RAW_TASK_TABLE = "zentao_tasks"
 
-var _ core.SubTaskEntryPoint = CollectStories
+var _ core.SubTaskEntryPoint = CollectTask
 
-func CollectStories(taskCtx core.SubTaskContext) errors.Error {
+func CollectTask(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
@@ -42,13 +42,13 @@ func CollectStories(taskCtx core.SubTaskContext) 
errors.Error {
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_TASK_TABLE,
                },
                ApiClient:   data.ApiClient,
                Incremental: false,
                PageSize:    100,
                // TODO write which api would you want request
-               UrlTemplate: "/executions/{{ .Params.ExecutionId }}/stories",
+               UrlTemplate: "/executions/{{ .Params.ExecutionId }}/tasks",
                Query: func(reqData *helper.RequestData) (url.Values, 
errors.Error) {
                        query := url.Values{}
                        query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page))
@@ -58,15 +58,15 @@ func CollectStories(taskCtx core.SubTaskContext) 
errors.Error {
                GetTotalPages: GetTotalPagesFromResponse,
                ResponseParser: func(res *http.Response) ([]json.RawMessage, 
errors.Error) {
                        var data struct {
-                               Stories []json.RawMessage `json:"stories"`
+                               Task []json.RawMessage `json:"tasks"`
                        }
                        body, err := io.ReadAll(res.Body)
                        err = json.Unmarshal(body, &data)
                        res.Body.Close()
                        if err != nil {
-                               return nil, errors.Default.Wrap(err, "error 
reading endpoint response by Zentao story collector")
+                               return nil, errors.Default.Wrap(err, "error 
reading endpoint response by Zentao task collector")
                        }
-                       return data.Stories, nil
+                       return data.Task, nil
                },
        })
        if err != nil {
@@ -76,9 +76,9 @@ func CollectStories(taskCtx core.SubTaskContext) errors.Error 
{
        return collector.Execute()
 }
 
-var CollectStoriesMeta = core.SubTaskMeta{
-       Name:             "CollectStories",
-       EntryPoint:       CollectStories,
+var CollectTaskMeta = core.SubTaskMeta{
+       Name:             "CollectTask",
+       EntryPoint:       CollectTask,
        EnabledByDefault: true,
-       Description:      "Collect Stories data from Zentao api",
+       Description:      "Collect Task data from Zentao api",
 }
diff --git a/plugins/zentao/tasks/stories_convertor.go 
b/plugins/zentao/tasks/task_convertor.go
similarity index 62%
rename from plugins/zentao/tasks/stories_convertor.go
rename to plugins/zentao/tasks/task_convertor.go
index 4b6c160b..79d0725c 100644
--- a/plugins/zentao/tasks/stories_convertor.go
+++ b/plugins/zentao/tasks/task_convertor.go
@@ -6,7 +6,7 @@ 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
+   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,
@@ -29,31 +29,31 @@ import (
        "reflect"
 )
 
-var _ core.SubTaskEntryPoint = ConvertStories
+var _ core.SubTaskEntryPoint = ConvertTask
 
-var ConvertStoriesMeta = core.SubTaskMeta{
-       Name:             "convertStories",
-       EntryPoint:       ConvertStories,
+var ConvertTaskMeta = core.SubTaskMeta{
+       Name:             "convertTask",
+       EntryPoint:       ConvertTask,
        EnabledByDefault: true,
-       Description:      "convert Zentao stories",
+       Description:      "convert Zentao task",
        DomainTypes:      []string{core.DOMAIN_TYPE_TICKET},
 }
 
-func ConvertStories(taskCtx core.SubTaskContext) errors.Error {
+func ConvertTask(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        db := taskCtx.GetDal()
-       boardIdGen := didgen.NewDomainIdGenerator(&models.ZentaoStories{})
+       boardIdGen := didgen.NewDomainIdGenerator(&models.ZentaoTask{})
        cursor, err := db.Cursor(
-               dal.From(&models.ZentaoStories{}),
-               dal.Where(`_tool_zentao_stories.execution_id = ? and 
-                       _tool_zentao_stories.connection_id = ?`, 
data.Options.ExecutionId, data.Options.ConnectionId),
+               dal.From(&models.ZentaoTask{}),
+               dal.Where(`_tool_zentao_tasks.execution_id = ? and 
+                       _tool_zentao_tasks.connection_id = ?`, 
data.Options.ExecutionId, data.Options.ConnectionId),
        )
        if err != nil {
                return err
        }
        defer cursor.Close()
        convertor, err := helper.NewDataConverter(helper.DataConverterArgs{
-               InputRowType: reflect.TypeOf(models.ZentaoStories{}),
+               InputRowType: reflect.TypeOf(models.ZentaoTask{}),
                Input:        cursor,
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
                        Ctx: taskCtx,
@@ -62,38 +62,37 @@ func ConvertStories(taskCtx core.SubTaskContext) 
errors.Error {
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_TASK_TABLE,
                },
                Convert: func(inputRow interface{}) ([]interface{}, 
errors.Error) {
-                       toolStories := inputRow.(*models.ZentaoStories)
+                       toolTask := inputRow.(*models.ZentaoTask)
 
                        domainBoard := &ticket.Issue{
                                DomainEntity: domainlayer.DomainEntity{
-                                       Id: 
boardIdGen.Generate(toolStories.ConnectionId, toolStories.ID),
+                                       Id: 
boardIdGen.Generate(toolTask.ConnectionId, toolTask.ID),
                                },
-                               Url:      "",
-                               IconURL:  "",
-                               IssueKey: "",
-                               Title:    toolStories.Title,
-                               //Description:             toolStories.Spec,
+                               Url:                     "",
+                               IconURL:                 "",
+                               IssueKey:                "",
+                               Title:                   toolTask.Name,
+                               Description:             toolTask.Desc,
                                EpicKey:                 "",
-                               Type:                    toolStories.Type,
-                               Status:                  toolStories.Status,
+                               Type:                    toolTask.Type,
+                               Status:                  toolTask.Status,
                                OriginalStatus:          "",
-                               StoryPoint:              0,
-                               ResolutionDate:          nil,
-                               CreatedDate:             
toolStories.OpenedDate.ToNullableTime(),
-                               UpdatedDate:             
toolStories.LastEditedDate.ToNullableTime(),
+                               ResolutionDate:          
toolTask.FinishedDate.ToNullableTime(),
+                               CreatedDate:             
toolTask.OpenedDate.ToNullableTime(),
+                               UpdatedDate:             
toolTask.LastEditedDate.ToNullableTime(),
                                LeadTimeMinutes:         0,
                                ParentIssueId:           "",
                                Priority:                "",
                                OriginalEstimateMinutes: 0,
                                TimeSpentMinutes:        0,
                                TimeRemainingMinutes:    0,
-                               CreatorId:               "",
-                               CreatorName:             
toolStories.OpenedBy.OpenedByRealname,
-                               AssigneeId:              "",
-                               AssigneeName:            
toolStories.AssignedTo.Realname,
+                               CreatorId:               
string(toolTask.OpenedBy.OpenedByID),
+                               CreatorName:             
toolTask.OpenedBy.OpenedByRealname,
+                               AssigneeId:              
string(toolTask.AssignedTo.AssignedToID),
+                               AssigneeName:            
toolTask.AssignedTo.AssignedToRealname,
                                Severity:                "",
                                Component:               "",
                                DeploymentId:            "",
diff --git a/plugins/zentao/tasks/stories_extractor.go 
b/plugins/zentao/tasks/task_extractor.go
similarity index 76%
rename from plugins/zentao/tasks/stories_extractor.go
rename to plugins/zentao/tasks/task_extractor.go
index 5c2bc3cf..bee53942 100644
--- a/plugins/zentao/tasks/stories_extractor.go
+++ b/plugins/zentao/tasks/task_extractor.go
@@ -25,17 +25,17 @@ import (
        "github.com/apache/incubator-devlake/plugins/zentao/models"
 )
 
-var _ core.SubTaskEntryPoint = ExtractStories
+var _ core.SubTaskEntryPoint = ExtractTask
 
-var ExtractStoriesMeta = core.SubTaskMeta{
-       Name:             "extractStories",
-       EntryPoint:       ExtractStories,
+var ExtractTaskMeta = core.SubTaskMeta{
+       Name:             "extractTask",
+       EntryPoint:       ExtractTask,
        EnabledByDefault: true,
-       Description:      "extract Zentao stories",
+       Description:      "extract Zentao task",
        DomainTypes:      []string{core.DOMAIN_TYPE_TICKET},
 }
 
-func ExtractStories(taskCtx core.SubTaskContext) errors.Error {
+func ExtractTask(taskCtx core.SubTaskContext) errors.Error {
        data := taskCtx.GetData().(*ZentaoTaskData)
        extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{
                RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
@@ -45,18 +45,18 @@ func ExtractStories(taskCtx core.SubTaskContext) 
errors.Error {
                                ExecutionId: data.Options.ExecutionId,
                                ProjectId:   data.Options.ProjectId,
                        },
-                       Table: RAW_STORIES_TABLE,
+                       Table: RAW_TASK_TABLE,
                },
                Extract: func(row *helper.RawData) ([]interface{}, 
errors.Error) {
-                       stories := &models.ZentaoStories{}
-                       err := json.Unmarshal(row.Data, stories)
+                       task := &models.ZentaoTask{}
+                       err := json.Unmarshal(row.Data, task)
                        if err != nil {
                                return nil, errors.Default.WrapRaw(err)
                        }
-                       stories.ConnectionId = data.Options.ConnectionId
-                       stories.ExecutionId = data.Options.ExecutionId
+                       task.ConnectionId = data.Options.ConnectionId
+                       task.ExecutionId = data.Options.ExecutionId
                        results := make([]interface{}, 0)
-                       results = append(results, stories)
+                       results = append(results, task)
                        return results, nil
                },
        })

Reply via email to