(taskCtx plugin.SubTaskContext)
| 42 | } |
| 43 | |
| 44 | func ExtractTasks(taskCtx plugin.SubTaskContext) errors.Error { |
| 45 | rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_TASK_TABLE) |
| 46 | getTaskStdStatus := func(statusKey string) string { |
| 47 | if statusKey == "done" { |
| 48 | return ticket.DONE |
| 49 | } else if statusKey == "progressing" { |
| 50 | return ticket.IN_PROGRESS |
| 51 | } else { |
| 52 | return ticket.TODO |
| 53 | } |
| 54 | } |
| 55 | stdTypeMappings := getStdTypeMappings(data) |
| 56 | // get due date field |
| 57 | dueDateField := "due" |
| 58 | if data.Options.ScopeConfig != nil && data.Options.ScopeConfig.TaskDueDateField != "" { |
| 59 | dueDateField = data.Options.ScopeConfig.TaskDueDateField |
| 60 | } |
| 61 | extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ |
| 62 | RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| 63 | BatchSize: 100, |
| 64 | Extract: func(row *api.RawData) ([]interface{}, errors.Error) { |
| 65 | var taskBody struct { |
| 66 | Task models.TapdTask |
| 67 | } |
| 68 | |
| 69 | err := errors.Convert(json.Unmarshal(row.Data, &taskBody)) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | toolL := taskBody.Task |
| 74 | err = errors.Convert(toolL.SetAllFields(row.Data)) |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | toolL.ConnectionId = data.Options.ConnectionId |
| 79 | toolL.Type = "TASK" |
| 80 | toolL.StdType = stdTypeMappings[toolL.Type] |
| 81 | if toolL.StdType == "" { |
| 82 | toolL.StdType = ticket.TASK |
| 83 | } |
| 84 | toolL.Priority = priorityMap[toolL.Priority] |
| 85 | toolL.StdStatus = getTaskStdStatus(toolL.Status) |
| 86 | if strings.Contains(toolL.Owner, ";") { |
| 87 | toolL.Owner = strings.Split(toolL.Owner, ";")[0] |
| 88 | } |
| 89 | toolL.Url = fmt.Sprintf("https://www.tapd.cn/%d/prong/tasks/view/%d", toolL.WorkspaceId, toolL.Id) |
| 90 | |
| 91 | workSpaceTask := &models.TapdWorkSpaceTask{ |
| 92 | ConnectionId: data.Options.ConnectionId, |
| 93 | WorkspaceId: toolL.WorkspaceId, |
| 94 | TaskId: toolL.Id, |
| 95 | } |
| 96 | results := make([]interface{}, 0, 3) |
| 97 | results = append(results, &toolL, workSpaceTask) |
| 98 | if toolL.IterationId != 0 { |
| 99 | iterationTask := &models.TapdIterationTask{ |
| 100 | ConnectionId: data.Options.ConnectionId, |
| 101 | IterationId: toolL.IterationId, |
nothing calls this directly
no test coverage detected