(taskCtx plugin.SubTaskContext)
| 42 | } |
| 43 | |
| 44 | func ExtractBugs(taskCtx plugin.SubTaskContext) errors.Error { |
| 45 | rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_BUG_TABLE) |
| 46 | db := taskCtx.GetDal() |
| 47 | statusList := make([]models.TapdBugStatus, 0) |
| 48 | statusLanguageMap, getStdStatus, err := getDefaultStdStatusMapping(data, db, statusList) |
| 49 | if err != nil { |
| 50 | return err |
| 51 | } |
| 52 | customStatusMap := getStatusMapping(data) |
| 53 | stdTypeMappings := getStdTypeMappings(data) |
| 54 | // get due date field |
| 55 | dueDateField := "due" |
| 56 | if data.Options.ScopeConfig != nil && data.Options.ScopeConfig.BugDueDateField != "" { |
| 57 | dueDateField = data.Options.ScopeConfig.BugDueDateField |
| 58 | } |
| 59 | extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ |
| 60 | RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| 61 | BatchSize: 100, |
| 62 | Extract: func(row *api.RawData) ([]interface{}, errors.Error) { |
| 63 | var bugBody struct { |
| 64 | Bug models.TapdBug |
| 65 | } |
| 66 | err = errors.Convert(json.Unmarshal(row.Data, &bugBody)) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | toolL := bugBody.Bug |
| 71 | err = errors.Convert(toolL.SetAllFields(row.Data)) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | toolL.Status = statusLanguageMap[toolL.Status] |
| 76 | toolL.ConnectionId = data.Options.ConnectionId |
| 77 | toolL.Type = "BUG" |
| 78 | toolL.StdType = stdTypeMappings[toolL.Type] |
| 79 | if toolL.StdType == "" { |
| 80 | toolL.StdType = ticket.BUG |
| 81 | } |
| 82 | if len(customStatusMap) != 0 { |
| 83 | toolL.StdStatus = customStatusMap[toolL.Status] |
| 84 | } else { |
| 85 | toolL.StdStatus = getStdStatus(toolL.Status) |
| 86 | } |
| 87 | toolL.Url = fmt.Sprintf("https://www.tapd.cn/%d/bugtrace/bugs/view?bug_id=%d", toolL.WorkspaceId, toolL.Id) |
| 88 | if strings.Contains(toolL.CurrentOwner, ";") { |
| 89 | toolL.CurrentOwner = strings.Split(toolL.CurrentOwner, ";")[0] |
| 90 | } |
| 91 | loc, _ := time.LoadLocation("Asia/Shanghai") |
| 92 | toolL.DueDate, _ = utils.GetTimeFieldFromMap(toolL.AllFields, dueDateField, loc) |
| 93 | workSpaceBug := &models.TapdWorkSpaceBug{ |
| 94 | ConnectionId: data.Options.ConnectionId, |
| 95 | WorkspaceId: toolL.WorkspaceId, |
| 96 | BugId: toolL.Id, |
| 97 | } |
| 98 | results := make([]interface{}, 0, 3) |
| 99 | results = append(results, &toolL, workSpaceBug) |
| 100 | if toolL.IterationId != 0 { |
| 101 | iterationBug := &models.TapdIterationBug{ |
nothing calls this directly
no test coverage detected