MCPcopy Index your code
hub / github.com/apache/devlake / ConvertTask

Function ConvertTask

backend/plugins/tapd/tasks/task_converter.go:35–112  ·  view source on GitHub ↗
(taskCtx plugin.SubTaskContext)

Source from the content-addressed store, hash-verified

33)
34
35func ConvertTask(taskCtx plugin.SubTaskContext) errors.Error {
36 rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_TASK_TABLE)
37 logger := taskCtx.GetLogger()
38 db := taskCtx.GetDal()
39 logger.Info("convert workspace: %d", data.Options.WorkspaceId)
40
41 clauses := []dal.Clause{
42 dal.From(&models.TapdTask{}),
43 dal.Where("connection_id = ? AND workspace_id = ?", data.Options.ConnectionId, data.Options.WorkspaceId),
44 }
45
46 cursor, err := db.Cursor(clauses...)
47 if err != nil {
48 return err
49 }
50 defer cursor.Close()
51 taskIdGen := didgen.NewDomainIdGenerator(&models.TapdTask{})
52 storyIdGen := didgen.NewDomainIdGenerator(&models.TapdStory{})
53 converter, err := helper.NewDataConverter(helper.DataConverterArgs{
54 RawDataSubTaskArgs: *rawDataSubTaskArgs,
55 InputRowType: reflect.TypeOf(models.TapdTask{}),
56 Input: cursor,
57 Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
58 toolL := inputRow.(*models.TapdTask)
59 domainL := &ticket.Issue{
60 DomainEntity: domainlayer.DomainEntity{
61 Id: taskIdGen.Generate(toolL.ConnectionId, toolL.Id),
62 },
63 Url: toolL.Url,
64 IssueKey: strconv.FormatUint(toolL.Id, 10),
65 Title: toolL.Name,
66 Description: toolL.Description,
67 Type: toolL.StdType,
68 OriginalType: toolL.Type,
69 Status: toolL.StdStatus,
70 OriginalStatus: toolL.Status,
71 ResolutionDate: (*time.Time)(toolL.Completed),
72 CreatedDate: (*time.Time)(toolL.Created),
73 UpdatedDate: (*time.Time)(toolL.Modified),
74 ParentIssueId: storyIdGen.Generate(toolL.ConnectionId, toolL.StoryId),
75 Priority: toolL.Priority,
76 CreatorId: getAccountIdGen().Generate(data.Options.ConnectionId, toolL.Creator),
77 CreatorName: toolL.Creator,
78 AssigneeName: toolL.Owner,
79 DueDate: toolL.DueDate,
80 }
81 var results []interface{}
82 if domainL.AssigneeName != "" {
83 domainL.AssigneeId = getAccountIdGen().Generate(data.Options.ConnectionId, toolL.Owner)
84 issueAssignee := &ticket.IssueAssignee{
85 IssueId: domainL.Id,
86 AssigneeId: domainL.AssigneeId,
87 AssigneeName: domainL.AssigneeName,
88 }
89 results = append(results, issueAssignee)
90 }
91 if domainL.ResolutionDate != nil && domainL.CreatedDate != nil {
92 temp := uint(domainL.ResolutionDate.Sub(*domainL.CreatedDate).Minutes())

Callers

nothing calls this directly

Calls 12

GenerateMethod · 0.95
ExecuteMethod · 0.95
getWorkspaceIdGenFunction · 0.85
getIterIdGenFunction · 0.85
CreateRawDataSubTaskArgsFunction · 0.70
getAccountIdGenFunction · 0.70
GetLoggerMethod · 0.65
GetDalMethod · 0.65
InfoMethod · 0.65
FromMethod · 0.65
CursorMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected