(subtaskCtx plugin.SubTaskContext)
| 48 | } |
| 49 | |
| 50 | func ExtractIssues(subtaskCtx plugin.SubTaskContext) errors.Error { |
| 51 | data := subtaskCtx.GetData().(*JiraTaskData) |
| 52 | db := subtaskCtx.GetDal() |
| 53 | connectionId := data.Options.ConnectionId |
| 54 | boardId := data.Options.BoardId |
| 55 | logger := subtaskCtx.GetLogger() |
| 56 | logger.Info("extract Issues, connection_id=%d, board_id=%d", connectionId, boardId) |
| 57 | mappings, err := getTypeMappings(data, db) |
| 58 | if err != nil { |
| 59 | return err |
| 60 | } |
| 61 | userFieldMap, err := getUserFieldMap(db, connectionId, logger) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | extractor, err := api.NewStatefulApiExtractor(&api.StatefulApiExtractorArgs[apiv2models.Issue]{ |
| 66 | SubtaskCommonArgs: &api.SubtaskCommonArgs{ |
| 67 | SubTaskContext: subtaskCtx, |
| 68 | Table: RAW_ISSUE_TABLE, |
| 69 | Params: JiraApiParams{ |
| 70 | ConnectionId: data.Options.ConnectionId, |
| 71 | BoardId: data.Options.BoardId, |
| 72 | }, |
| 73 | SubtaskConfig: map[string]any{ |
| 74 | "typeMappings": mappings, |
| 75 | "storyPointField": data.Options.ScopeConfig.StoryPointField, |
| 76 | "dueDateField": data.Options.ScopeConfig.DueDateField, |
| 77 | }, |
| 78 | }, |
| 79 | BeforeExtract: func(apiIssue *apiv2models.Issue, stateManager *api.SubtaskStateManager) errors.Error { |
| 80 | if stateManager.IsIncremental() { |
| 81 | err := db.Delete( |
| 82 | &models.JiraIssueLabel{}, |
| 83 | dal.Where("connection_id = ? AND issue_id = ?", data.Options.ConnectionId, apiIssue.ID), |
| 84 | ) |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | err = db.Delete( |
| 89 | &models.JiraIssueRelationship{}, |
| 90 | dal.Where("connection_id = ? AND issue_id = ?", data.Options.ConnectionId, apiIssue.ID), |
| 91 | ) |
| 92 | if err != nil { |
| 93 | return err |
| 94 | } |
| 95 | } |
| 96 | return nil |
| 97 | }, |
| 98 | Extract: func(apiIssue *apiv2models.Issue, row *api.RawData) ([]interface{}, errors.Error) { |
| 99 | return extractIssues(data, mappings, apiIssue, row, userFieldMap) |
| 100 | }, |
| 101 | }) |
| 102 | if err != nil { |
| 103 | return err |
| 104 | } |
| 105 | return extractor.Execute() |
| 106 | } |
| 107 |
nothing calls this directly
no test coverage detected