You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "abeizn (via GitHub)" <gi...@apache.org> on 2023/02/08 07:34:18 UTC

[GitHub] [incubator-devlake] abeizn opened a new pull request, #4357: feat: account and issues code block convertor

abeizn opened a new pull request, #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357

   ### Summary
   feat: account and issues code block convertor
   
   ### Does this close any open issues?
   part of #2305 
   
   ### Screenshots
   ![Uploading image.png…]()
   
   
   ### Other Information
   Any other information that is important to this PR.
   


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099872607


##########
backend/plugins/sonarqube/tasks/issue_code_blocks_convertor.go:
##########
@@ -0,0 +1,84 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/models/domainlayer/securitytesting"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertIssueCodeBlocks(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_ISSUES_TABLE)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeIssueCodeBlock{}), dal.Where("connection_id = ? and project = ? ",
+		data.Options.ConnectionId, data.Options.ProjectKey))

Review Comment:
   Maybe we should not add project for code block, and use join issues to find this... I am sorry



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099768706


##########
backend/plugins/sonarqube/tasks/issue_code_blocks_convertor.go:
##########
@@ -0,0 +1,89 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/models/domainlayer/securitytesting"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertIssueCodeBlocks(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*SonarqubeTaskData)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeIssueCodeBlock{}), dal.Where("connection_id = ?", data.Options.ConnectionId))

Review Comment:
   please add `key` = ?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 merged pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 merged PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099769271


##########
backend/plugins/sonarqube/tasks/issue_code_blocks_convertor.go:
##########
@@ -0,0 +1,89 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/models/domainlayer/securitytesting"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertIssueCodeBlocks(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*SonarqubeTaskData)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeIssueCodeBlock{}), dal.Where("connection_id = ?", data.Options.ConnectionId))
+	if err != nil {
+		return err
+	}
+	defer cursor.Close()
+
+	idGen := didgen.NewDomainIdGenerator(&models.SonarqubeIssueCodeBlock{})
+	converter, err := api.NewDataConverter(api.DataConverterArgs{
+		InputRowType: reflect.TypeOf(models.SonarqubeIssueCodeBlock{}),
+		Input:        cursor,
+		RawDataSubTaskArgs: api.RawDataSubTaskArgs{
+			Ctx: taskCtx,
+			Params: SonarqubeApiParams{
+				ConnectionId: data.Options.ConnectionId,
+				ProjectKey:   data.Options.ProjectKey,
+			},
+			Table: RAW_ISSUES_TABLE,
+		},
+		Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
+			sonarqubeIssueCodeBlock := inputRow.(*models.SonarqubeIssueCodeBlock)
+			domainIssueCodeBlock := &securitytesting.StIssueCodeBlock{
+				DomainEntity: domainlayer.DomainEntity{Id: idGen.Generate(data.Options.ConnectionId, sonarqubeIssueCodeBlock.Id)},
+				Id:           sonarqubeIssueCodeBlock.Id,
+				IssueKey:     sonarqubeIssueCodeBlock.IssueKey,
+				Component:    sonarqubeIssueCodeBlock.Component,
+				Msg:          sonarqubeIssueCodeBlock.Msg,
+				StartLine:    sonarqubeIssueCodeBlock.StartLine,
+				EndLine:      sonarqubeIssueCodeBlock.EndLine,
+				StartOffset:  sonarqubeIssueCodeBlock.StartOffset,
+				EndOffset:    sonarqubeIssueCodeBlock.EndOffset,
+			}
+
+			return []interface{}{
+				domainIssueCodeBlock,
+			}, nil
+		},
+	})
+
+	if err != nil {
+		return err
+	}
+
+	return converter.Execute()
+}
+
+var ConvertIssueCodeBlocksMeta = plugin.SubTaskMeta{
+	Name:             "convertIssueCodeBlocks",
+	EntryPoint:       ConvertIssueCodeBlocks,
+	EnabledByDefault: true,
+	Description:      "Convert tool layer table sonarqube_accounts into domain layer table accounts",
+	DomainTypes:      []string{plugin.DOMAIN_TYPE_CROSS},

Review Comment:
   not type_cross



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099768924


##########
backend/plugins/sonarqube/tasks/account_convertor.go:
##########
@@ -0,0 +1,83 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertAccounts(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*SonarqubeTaskData)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeAccount{}), dal.Where("connection_id = ?", data.Options.ConnectionId))

Review Comment:
   please add key = ?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099768924


##########
backend/plugins/sonarqube/tasks/account_convertor.go:
##########
@@ -0,0 +1,83 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/crossdomain"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertAccounts(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*SonarqubeTaskData)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeAccount{}), dal.Where("connection_id = ?", data.Options.ConnectionId))

Review Comment:
   please add key = ?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099870006


##########
backend/core/models/migrationscripts/archived/st_issue_code_blocks.go:
##########
@@ -0,0 +1,35 @@
+/*
+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 archived
+
+type StIssueCodeBlock struct {
+	DomainEntity
+	Id          string `gorm:"primaryKey"`

Review Comment:
   this should not be primaryKey



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] warren830 commented on a diff in pull request #4357: feat: account and issues code block convertor

Posted by "warren830 (via GitHub)" <gi...@apache.org>.
warren830 commented on code in PR #4357:
URL: https://github.com/apache/incubator-devlake/pull/4357#discussion_r1099769133


##########
backend/plugins/sonarqube/tasks/issue_code_blocks_convertor.go:
##########
@@ -0,0 +1,89 @@
+/*
+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 (
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/models/domainlayer/securitytesting"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/sonarqube/models"
+)
+
+func ConvertIssueCodeBlocks(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*SonarqubeTaskData)
+
+	cursor, err := db.Cursor(dal.From(&models.SonarqubeIssueCodeBlock{}), dal.Where("connection_id = ?", data.Options.ConnectionId))
+	if err != nil {
+		return err
+	}
+	defer cursor.Close()
+
+	idGen := didgen.NewDomainIdGenerator(&models.SonarqubeIssueCodeBlock{})
+	converter, err := api.NewDataConverter(api.DataConverterArgs{
+		InputRowType: reflect.TypeOf(models.SonarqubeIssueCodeBlock{}),
+		Input:        cursor,
+		RawDataSubTaskArgs: api.RawDataSubTaskArgs{
+			Ctx: taskCtx,
+			Params: SonarqubeApiParams{
+				ConnectionId: data.Options.ConnectionId,
+				ProjectKey:   data.Options.ProjectKey,
+			},
+			Table: RAW_ISSUES_TABLE,
+		},
+		Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
+			sonarqubeIssueCodeBlock := inputRow.(*models.SonarqubeIssueCodeBlock)
+			domainIssueCodeBlock := &securitytesting.StIssueCodeBlock{
+				DomainEntity: domainlayer.DomainEntity{Id: idGen.Generate(data.Options.ConnectionId, sonarqubeIssueCodeBlock.Id)},
+				Id:           sonarqubeIssueCodeBlock.Id,
+				IssueKey:     sonarqubeIssueCodeBlock.IssueKey,
+				Component:    sonarqubeIssueCodeBlock.Component,
+				Msg:          sonarqubeIssueCodeBlock.Msg,
+				StartLine:    sonarqubeIssueCodeBlock.StartLine,
+				EndLine:      sonarqubeIssueCodeBlock.EndLine,
+				StartOffset:  sonarqubeIssueCodeBlock.StartOffset,
+				EndOffset:    sonarqubeIssueCodeBlock.EndOffset,
+			}
+
+			return []interface{}{
+				domainIssueCodeBlock,
+			}, nil
+		},
+	})
+
+	if err != nil {
+		return err
+	}
+
+	return converter.Execute()
+}
+
+var ConvertIssueCodeBlocksMeta = plugin.SubTaskMeta{
+	Name:             "convertIssueCodeBlocks",
+	EntryPoint:       ConvertIssueCodeBlocks,
+	EnabledByDefault: true,
+	Description:      "Convert tool layer table sonarqube_accounts into domain layer table accounts",

Review Comment:
   not accounts here
   



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org