(taskCtx plugin.SubTaskContext)
| 60 | } |
| 61 | |
| 62 | func ExtractApiCommits(taskCtx plugin.SubTaskContext) errors.Error { |
| 63 | rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_COMMIT_TABLE) |
| 64 | |
| 65 | extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ |
| 66 | RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| 67 | Extract: func(row *api.RawData) ([]interface{}, errors.Error) { |
| 68 | results := make([]interface{}, 0, 4) |
| 69 | |
| 70 | commit := &GiteeApiCommitResponse{} |
| 71 | |
| 72 | err := errors.Convert(json.Unmarshal(row.Data, commit)) |
| 73 | |
| 74 | if err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | |
| 78 | if commit.Sha == "" { |
| 79 | return nil, nil |
| 80 | } |
| 81 | |
| 82 | giteeCommit, err := ConvertCommit(commit) |
| 83 | |
| 84 | if err != nil { |
| 85 | return nil, err |
| 86 | } |
| 87 | |
| 88 | if commit.Author != nil { |
| 89 | giteeCommit.AuthorId = commit.Author.Id |
| 90 | results = append(results, commit.Author) |
| 91 | } |
| 92 | if commit.Committer != nil { |
| 93 | giteeCommit.CommitterId = commit.Committer.Id |
| 94 | results = append(results, commit.Committer) |
| 95 | } |
| 96 | |
| 97 | giteeRepoCommit := &models.GiteeRepoCommit{ |
| 98 | ConnectionId: data.Options.ConnectionId, |
| 99 | RepoId: data.Repo.GiteeId, |
| 100 | CommitSha: commit.Sha, |
| 101 | } |
| 102 | results = append(results, giteeCommit) |
| 103 | results = append(results, giteeRepoCommit) |
| 104 | return results, nil |
| 105 | }, |
| 106 | }) |
| 107 | |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | return extractor.Execute() |
| 113 | } |
| 114 | |
| 115 | // ConvertCommit Convert the API response to our DB model instance |
| 116 | func ConvertCommit(commit *GiteeApiCommitResponse) (*models.GiteeCommit, errors.Error) { |
nothing calls this directly
no test coverage detected