(taskCtx plugin.SubTaskContext)
| 42 | } |
| 43 | |
| 44 | func ExtractStories(taskCtx plugin.SubTaskContext) errors.Error { |
| 45 | rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_STORY_TABLE) |
| 46 | db := taskCtx.GetDal() |
| 47 | statusList := make([]models.TapdStoryStatus, 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 | typeIdMapping, err := getTapdTypeMappings(data, db, "story") |
| 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | // get due date field |
| 59 | dueDateField := "due" |
| 60 | if data.Options.ScopeConfig != nil && data.Options.ScopeConfig.StoryDueDateField != "" { |
| 61 | dueDateField = data.Options.ScopeConfig.StoryDueDateField |
| 62 | } |
| 63 | extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ |
| 64 | RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| 65 | BatchSize: 100, |
| 66 | Extract: func(row *api.RawData) ([]interface{}, errors.Error) { |
| 67 | var storyBody struct { |
| 68 | Story models.TapdStory |
| 69 | } |
| 70 | err = errors.Convert(json.Unmarshal(row.Data, &storyBody)) |
| 71 | if err != nil { |
| 72 | return nil, err |
| 73 | } |
| 74 | toolL := storyBody.Story |
| 75 | err = errors.Convert(toolL.SetAllFields(row.Data)) |
| 76 | if err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | toolL.Status = statusLanguageMap[toolL.Status] |
| 80 | if len(customStatusMap) != 0 { |
| 81 | toolL.StdStatus = customStatusMap[toolL.Status] |
| 82 | } else { |
| 83 | toolL.StdStatus = getStdStatus(toolL.Status) |
| 84 | } |
| 85 | |
| 86 | toolL.ConnectionId = data.Options.ConnectionId |
| 87 | toolL.Priority = priorityMap[toolL.Priority] |
| 88 | toolL.Type = typeIdMapping[toolL.WorkitemTypeId] |
| 89 | toolL.StdType = stdTypeMappings[toolL.Type] |
| 90 | if toolL.StdType == "" { |
| 91 | toolL.StdType = ticket.REQUIREMENT |
| 92 | } |
| 93 | |
| 94 | toolL.Url = fmt.Sprintf("https://www.tapd.cn/%d/prong/stories/view/%d", toolL.WorkspaceId, toolL.Id) |
| 95 | if strings.Contains(toolL.Owner, ";") { |
| 96 | toolL.Owner = strings.Split(toolL.Owner, ";")[0] |
| 97 | } |
| 98 | workSpaceStory := &models.TapdWorkSpaceStory{ |
| 99 | ConnectionId: data.Options.ConnectionId, |
| 100 | WorkspaceId: toolL.WorkspaceId, |
| 101 | StoryId: toolL.Id, |
nothing calls this directly
no test coverage detected