klesh commented on code in PR #4359:
URL:
https://github.com/apache/incubator-devlake/pull/4359#discussion_r1102783890
##########
backend/plugins/gitlab/tasks/account_extractor.go:
##########
@@ -65,5 +67,10 @@ func ExtractAccounts(taskCtx plugin.SubTaskContext)
errors.Error {
return err
}
- return extractor.Execute()
+ err = extractor.Execute()
Review Comment:
Why?
##########
backend/plugins/gitlab/tasks/mr_detail_extractor.go:
##########
@@ -0,0 +1,121 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "encoding/json"
+ "regexp"
+
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+ "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+ "github.com/apache/incubator-devlake/plugins/gitlab/models"
+)
+
+var ExtractApiMergeRequestDetailsMeta = plugin.SubTaskMeta{
+ Name: "extractApiMergeRequestDetails",
+ EntryPoint: ExtractApiMergeRequestDetails,
+ EnabledByDefault: true,
+ Description: "Extract raw merge request Details data into tool
layer table GitlabMergeRequest and GitlabReviewer",
+ DomainTypes: []string{plugin.DOMAIN_TYPE_CODE_REVIEW},
+}
+
+func ExtractApiMergeRequestDetails(taskCtx plugin.SubTaskContext) errors.Error
{
+ rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx,
RAW_MERGE_REQUEST_DETAIL_TABLE)
+ config := data.Options.GitlabTransformationRule
+ var labelTypeRegex *regexp.Regexp
+ var labelComponentRegex *regexp.Regexp
+ var prType = config.PrType
+ var err error
+ if len(prType) > 0 {
+ labelTypeRegex, err = regexp.Compile(prType)
+ if err != nil {
+ return errors.Default.Wrap(err, "regexp Compile prType
failed")
+ }
+ }
+ var prComponent = config.PrComponent
+ if len(prComponent) > 0 {
+ labelComponentRegex, err = regexp.Compile(prComponent)
+ if err != nil {
+ return errors.Default.Wrap(err, "regexp Compile
prComponent failed")
+ }
+ }
+ extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
+ RawDataSubTaskArgs: *rawDataSubTaskArgs,
+ Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
+ mr := &MergeRequestRes{}
+ err := errors.Convert(json.Unmarshal(row.Data, mr))
+ if err != nil {
+ return nil, err
+ }
+
+ gitlabMergeRequest, err := convertMergeRequest(mr)
+ if err != nil {
+ return nil, err
+ }
+ results := make([]interface{}, 0, len(mr.Reviewers)+1)
+ gitlabMergeRequest.ConnectionId =
data.Options.ConnectionId
+ gitlabMergeRequest.IsDetailRequired = true
Review Comment:
This should be `false` since we can be sure that detail HAS BEEN COLLECTED
at this point, right?
##########
backend/plugins/gitlab/tasks/pipeline_detail_extractor.go:
##########
@@ -0,0 +1,90 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "encoding/json"
+
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+ "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+ "github.com/apache/incubator-devlake/plugins/gitlab/models"
+)
+
+var ExtractApiPipelineDetailsMeta = plugin.SubTaskMeta{
+ Name: "extractApiPipelineDetails",
+ EntryPoint: ExtractApiPipelineDetails,
+ EnabledByDefault: true,
+ Description: "Extract raw pipeline details data into tool layer
table GitlabPipeline",
+ DomainTypes: []string{plugin.DOMAIN_TYPE_CICD},
+}
+
+func ExtractApiPipelineDetails(taskCtx plugin.SubTaskContext) errors.Error {
+ rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx,
RAW_PIPELINE_DETAILS_TABLE)
+
+ extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
+ RawDataSubTaskArgs: *rawDataSubTaskArgs,
+ Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
+ // create gitlab commit
+ gitlabApiPipeline := &ApiPipeline{}
+ err := errors.Convert(json.Unmarshal(row.Data,
gitlabApiPipeline))
+ if err != nil {
+ return nil, err
+ }
+
+ if gitlabApiPipeline.UpdatedAt != nil &&
gitlabApiPipeline.CreatedAt != nil {
+ gitlabApiPipeline.Duration =
int(gitlabApiPipeline.UpdatedAt.ToTime().Sub(gitlabApiPipeline.CreatedAt.ToTime()).Seconds())
+ }
+ gitlabPipeline := &models.GitlabPipeline{
+ GitlabId: gitlabApiPipeline.Id,
+ ProjectId: data.Options.ProjectId,
+ WebUrl: gitlabApiPipeline.WebUrl,
+ Status: gitlabApiPipeline.Status,
+ GitlabCreatedAt:
api.Iso8601TimeToTime(gitlabApiPipeline.CreatedAt),
+ GitlabUpdatedAt:
api.Iso8601TimeToTime(gitlabApiPipeline.UpdatedAt),
+ StartedAt:
api.Iso8601TimeToTime(gitlabApiPipeline.StartedAt),
+ FinishedAt:
api.Iso8601TimeToTime(gitlabApiPipeline.FinishedAt),
+ Duration: gitlabApiPipeline.Duration,
+ ConnectionId: data.Options.ConnectionId,
+ IsDetailRequired: true,
Review Comment:
Same as above
##########
backend/plugins/gitlab/tasks/mr_extractor.go:
##########
@@ -155,7 +170,12 @@ func ExtractApiMergeRequests(taskCtx
plugin.SubTaskContext) errors.Error {
return errors.Convert(err)
}
- return extractor.Execute()
Review Comment:
why...
##########
backend/plugins/gitlab/tasks/pipeline_extractor.go:
##########
@@ -112,5 +116,10 @@ func ExtractApiPipelines(taskCtx plugin.SubTaskContext)
errors.Error {
return err
}
- return extractor.Execute()
Review Comment:
Why?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]