thenicetgp commented on code in PR #1968:
URL: https://github.com/apache/incubator-devlake/pull/1968#discussion_r880021056


##########
plugins/gitlab/tasks/issue_convertor.go:
##########
@@ -0,0 +1,89 @@
+package tasks
+
+import (
+       "reflect"
+       "strconv"
+
+       "github.com/merico-dev/lake/plugins/core"
+       "github.com/merico-dev/lake/plugins/helper"
+
+       "github.com/merico-dev/lake/models/domainlayer"
+       "github.com/merico-dev/lake/models/domainlayer/didgen"
+       "github.com/merico-dev/lake/models/domainlayer/ticket"
+       gitlabModels "github.com/merico-dev/lake/plugins/gitlab/models"
+)
+
+var ConvertIssuesMeta = core.SubTaskMeta{
+       Name:             "convertIssues",
+       EntryPoint:       ConvertIssues,
+       EnabledByDefault: true,
+       Description:      "Convert tool layer table gitlab_issues into  domain 
layer table issues",
+}
+
+func ConvertIssues(taskCtx core.SubTaskContext) error {
+       db := taskCtx.GetDb()
+       data := taskCtx.GetData().(*GitlabTaskData)
+       projectId := data.ProjectCommit.GitlabProjectId
+
+       issue := &gitlabModels.GitlabIssue{}
+       cursor, err := db.Model(issue).Where("project_id = ?", projectId).Rows()
+
+       if err != nil {
+               return err
+       }
+       defer cursor.Close()
+
+       issueIdGen := didgen.NewDomainIdGenerator(&gitlabModels.GitlabIssue{})
+       userIdGen := didgen.NewDomainIdGenerator(&gitlabModels.GitlabUser{})
+       boardIdGen := didgen.NewDomainIdGenerator(&gitlabModels.GitlabProject{})
+
+       converter, err := helper.NewDataConverter(helper.DataConverterArgs{
+               RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
+                       Ctx: taskCtx,
+                       Params: GitlabApiParams{
+                               ProjectId: data.Options.ProjectId,
+                       },
+                       Table: RAW_ISSUE_TABLE,
+               },
+               InputRowType: reflect.TypeOf(gitlabModels.GitlabIssue{}),
+               Input:        cursor,
+               Convert: func(inputRow interface{}) ([]interface{}, error) {
+                       issue := inputRow.(*gitlabModels.GitlabIssue)
+                       domainIssue := &ticket.Issue{
+                               DomainEntity:    domainlayer.DomainEntity{Id: 
issueIdGen.Generate(issue.GitlabId)},
+                               Number:          strconv.Itoa(issue.Number),
+                               Title:           issue.Title,
+                               Description:     issue.Body,
+                               Priority:        issue.Priority,
+                               Type:            issue.Type,
+                               AssigneeId:      
userIdGen.Generate(issue.AssigneeId),
+                               AssigneeName:    issue.AssigneeName,
+                               LeadTimeMinutes: issue.LeadTimeMinutes,
+                               Url:             issue.Url,
+                               CreatedDate:     &issue.GitlabCreatedAt,
+                               UpdatedDate:     &issue.GitlabUpdatedAt,
+                               ResolutionDate:  issue.ClosedAt,
+                               Severity:        issue.Severity,
+                               Component:       issue.Component,
+                       }
+                       if issue.State == "closed" {

Review Comment:
   How to understand “OriginalStatus need to be assigned value”, is there any 
other place that needs to be assigned a value?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to