You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/12/01 04:58:06 UTC

[GitHub] [incubator-devlake] warren830 opened a new pull request, #3828: fix(plugins): rename transformation rules

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

   ### Summary
   According to #3468 , we added transformationRules, but because of swagger parsing, we need to add `pluginName` as prefix for all  models.transformationRules
   
   ### Does this close any open issues?
   Relate to #3468 
   
   ### Screenshots
   Include any relevant screenshots here.
   
   ### 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] likyh merged pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh merged PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828


-- 
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] likyh commented on a diff in pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036709673


##########
plugins/jenkins/models/transformation_rule.go:
##########
@@ -19,12 +19,12 @@ package models
 
 import "github.com/apache/incubator-devlake/models/common"
 
-type TransformationRules struct {
+type JenkinsTransformationRule struct {
 	common.Model      `mapstructure:"-"`
-	Name              string `gorm:"type:varchar(255)" mapstructure:"name" json:"name"`
+	Name              string `gorm:"type:varchar(255)"`

Review Comment:
   why delete `mapstructure`?



-- 
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] likyh commented on a diff in pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036709673


##########
plugins/jenkins/models/transformation_rule.go:
##########
@@ -19,12 +19,12 @@ package models
 
 import "github.com/apache/incubator-devlake/models/common"
 
-type TransformationRules struct {
+type JenkinsTransformationRule struct {
 	common.Model      `mapstructure:"-"`
-	Name              string `gorm:"type:varchar(255)" mapstructure:"name" json:"name"`
+	Name              string `gorm:"type:varchar(255)"`

Review Comment:
   why delete `mapstructure` & `json`?



-- 
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] likyh commented on a diff in pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036708144


##########
plugins/github/api/blueprint_V200_test.go:
##########
@@ -88,13 +88,17 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
 			CreatedDate:  time.Time{},
 		}
 
-		transformationRule := &models.TransformationRules{
+		transformationRule := &models.GithubTransformationRule{
 			Model: common.Model{
 				ID: 1,
 			},
 			Name:    "github transformation rule",
-			PrType:  "hey,man,wasup",
-			Refdiff: json.RawMessage(`{"tagsPattern": "pattern", "tagsLimit": 10, "tagsOrder": "reverse semver"}`),
+			PrType: "hey,man,wasup",
+			Refdiff: map[string]interface{}{
+				"tagsPattern": "pattern",
+				"tagsLimit":   10,
+				"tagsOrder":   "reverse semver",
+			},

Review Comment:
   add this change to in PR desc.



##########
plugins/github/api/blueprint_V200_test.go:
##########
@@ -88,13 +88,17 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
 			CreatedDate:  time.Time{},
 		}
 
-		transformationRule := &models.TransformationRules{
+		transformationRule := &models.GithubTransformationRule{
 			Model: common.Model{
 				ID: 1,
 			},
 			Name:    "github transformation rule",
-			PrType:  "hey,man,wasup",
-			Refdiff: json.RawMessage(`{"tagsPattern": "pattern", "tagsLimit": 10, "tagsOrder": "reverse semver"}`),
+			PrType: "hey,man,wasup",
+			Refdiff: map[string]interface{}{
+				"tagsPattern": "pattern",
+				"tagsLimit":   10,
+				"tagsOrder":   "reverse semver",
+			},

Review Comment:
   add this change to PR desc.



-- 
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] likyh commented on a diff in pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036708144


##########
plugins/github/api/blueprint_V200_test.go:
##########
@@ -88,13 +88,17 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
 			CreatedDate:  time.Time{},
 		}
 
-		transformationRule := &models.TransformationRules{
+		transformationRule := &models.GithubTransformationRule{
 			Model: common.Model{
 				ID: 1,
 			},
 			Name:    "github transformation rule",
-			PrType:  "hey,man,wasup",
-			Refdiff: json.RawMessage(`{"tagsPattern": "pattern", "tagsLimit": 10, "tagsOrder": "reverse semver"}`),
+			PrType: "hey,man,wasup",
+			Refdiff: map[string]interface{}{
+				"tagsPattern": "pattern",
+				"tagsLimit":   10,
+				"tagsOrder":   "reverse semver",
+			},

Review Comment:
   add this change into PR desc.



-- 
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] likyh commented on a diff in pull request #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036710166


##########
plugins/jira/api/transformation_rule.go:
##########
@@ -86,20 +87,32 @@ func UpdateTransformationRule(input *core.ApiResourceInput) (*core.ApiResourceOu
 }
 
 func makeDbTransformationRuleFromInput(input *core.ApiResourceInput) (*models.JiraTransformationRule, errors.Error) {
-	var req tasks.TransformationRules
+	var req tasks.JiraTransformationRule
 	err := mapstructure.Decode(input.Body, &req)
 	if err != nil {
 		return nil, errors.Default.Wrap(err, "error decoding map into transformationRule")
 	}
-	return req.ToDb()
+	return makeDbTransformationRule(&req)
+}
+func makeDbTransformationRule(rule *tasks.JiraTransformationRule) (*models.JiraTransformationRule, errors.Error) {
+	blob, err := json.Marshal(rule.TypeMappings)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error marshaling TypeMappings")
+	}
+	return &models.JiraTransformationRule{
+		EpicKeyField:               rule.EpicKeyField,
+		StoryPointField:            rule.StoryPointField,
+		RemotelinkCommitShaPattern: rule.RemotelinkCommitShaPattern,
+		TypeMappings:               blob,
+	}, nil

Review Comment:
   this code delete in https://github.com/apache/incubator-devlake/pull/3827. It looks like a rebase bug.



-- 
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 #3828: fix(plugins): rename transformation rules

Posted by GitBox <gi...@apache.org>.
warren830 commented on code in PR #3828:
URL: https://github.com/apache/incubator-devlake/pull/3828#discussion_r1036760461


##########
plugins/jenkins/models/transformation_rule.go:
##########
@@ -19,12 +19,12 @@ package models
 
 import "github.com/apache/incubator-devlake/models/common"
 
-type TransformationRules struct {
+type JenkinsTransformationRule struct {
 	common.Model      `mapstructure:"-"`
-	Name              string `gorm:"type:varchar(255)" mapstructure:"name" json:"name"`
+	Name              string `gorm:"type:varchar(255)"`

Review Comment:
   fixed



##########
plugins/jira/api/transformation_rule.go:
##########
@@ -86,20 +87,32 @@ func UpdateTransformationRule(input *core.ApiResourceInput) (*core.ApiResourceOu
 }
 
 func makeDbTransformationRuleFromInput(input *core.ApiResourceInput) (*models.JiraTransformationRule, errors.Error) {
-	var req tasks.TransformationRules
+	var req tasks.JiraTransformationRule
 	err := mapstructure.Decode(input.Body, &req)
 	if err != nil {
 		return nil, errors.Default.Wrap(err, "error decoding map into transformationRule")
 	}
-	return req.ToDb()
+	return makeDbTransformationRule(&req)
+}
+func makeDbTransformationRule(rule *tasks.JiraTransformationRule) (*models.JiraTransformationRule, errors.Error) {
+	blob, err := json.Marshal(rule.TypeMappings)
+	if err != nil {
+		return nil, errors.Default.Wrap(err, "error marshaling TypeMappings")
+	}
+	return &models.JiraTransformationRule{
+		EpicKeyField:               rule.EpicKeyField,
+		StoryPointField:            rule.StoryPointField,
+		RemotelinkCommitShaPattern: rule.RemotelinkCommitShaPattern,
+		TypeMappings:               blob,
+	}, nil

Review Comment:
   fixed



-- 
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