This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new f671e612c fix(pluginhelper): add transformation rule name to response 
(#4755)
f671e612c is described below

commit f671e612cc5a38e038f267410d4105546c7d642d
Author: Warren Chen <[email protected]>
AuthorDate: Thu Mar 23 18:34:55 2023 +0800

    fix(pluginhelper): add transformation rule name to response (#4755)
    
    * fix(pluginhelper): add transformation rule name to response
    
    * fix(e2e): fix lint
---
 .github/workflows/test-e2e.yml                       |  4 +++-
 backend/helpers/pluginhelper/api/scope_helper.go     | 20 +++++++++++++++++++-
 .../pluginhelper/api/transformation_rule_helper.go   |  6 ------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml
index 234f5e315..1a734dd1d 100644
--- a/.github/workflows/test-e2e.yml
+++ b/.github/workflows/test-e2e.yml
@@ -34,7 +34,7 @@ jobs:
     runs-on: ubuntu-latest
     services:
       db:
-        image: mysql:8.0.26
+        image: mysql:8
         env:
           MYSQL_DATABASE: lake
           MYSQL_USER: merico
@@ -58,6 +58,7 @@ jobs:
           DB_URL: mysql://root:root@db:3306/lake?charset=utf8mb4&parseTime=True
           E2E_DB_URL: 
mysql://root:root@db:3306/lake?charset=utf8mb4&parseTime=True
         run: |
+          git config --global --add safe.directory 
/__w/incubator-devlake/incubator-devlake
           cp .env.example backend/.env
           cd backend
           make e2e-test
@@ -90,6 +91,7 @@ jobs:
           DB_URL: postgres://merico:merico@db:5432/lake
           E2E_DB_URL: postgres://merico:merico@db:5432/lake
         run: |
+          git config --global --add safe.directory 
/__w/incubator-devlake/incubator-devlake
           cp .env.example backend/.env
           cd backend
           make e2e-test
diff --git a/backend/helpers/pluginhelper/api/scope_helper.go 
b/backend/helpers/pluginhelper/api/scope_helper.go
index 8280e0e1d..74923bf90 100644
--- a/backend/helpers/pluginhelper/api/scope_helper.go
+++ b/backend/helpers/pluginhelper/api/scope_helper.go
@@ -156,10 +156,28 @@ func (c *ScopeApiHelper[Conn, Scope, Tr]) Update(input 
*plugin.ApiResourceInput,
        if err != nil {
                return &plugin.ApiResourceOutput{Body: nil, Status: 
http.StatusInternalServerError}, errors.Default.Wrap(err, "error on saving 
Scope")
        }
-       return &plugin.ApiResourceOutput{Body: &scope, Status: http.StatusOK}, 
nil
+       valueRepoRuleId := 
reflect.ValueOf(scope).FieldByName("TransformationRuleId")
+       if !valueRepoRuleId.IsValid() {
+               return &plugin.ApiResourceOutput{Body: scope, Status: 
http.StatusOK}, nil
+       }
+       repoRuleId := 
reflect.ValueOf(scope).FieldByName("TransformationRuleId").Uint()
+       var rule Tr
+       if repoRuleId > 0 {
+               err = c.db.First(&rule, dal.Where("id = ?", repoRuleId))
+               if err != nil {
+                       return nil, errors.NotFound.New("transformationRule not 
found")
+               }
+       }
+       scopeRes := &ScopeRes[Scope]{scope, 
reflect.ValueOf(rule).FieldByName("Name").String()}
+
+       return &plugin.ApiResourceOutput{Body: scopeRes, Status: 
http.StatusOK}, nil
 }
 
+// GetScopeList returns a list of scopes. It expects a fieldName argument, 
which is used
+// to extract the connection ID from the input.Params map.
+
 func (c *ScopeApiHelper[Conn, Scope, Tr]) GetScopeList(input 
*plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
+       // Extract the connection ID from the input.Params map
        connectionId, _ := extractFromReqParam(input.Params)
        if connectionId == 0 {
                return nil, errors.BadInput.New("invalid path params")
diff --git a/backend/helpers/pluginhelper/api/transformation_rule_helper.go 
b/backend/helpers/pluginhelper/api/transformation_rule_helper.go
index a819c10b7..645cc1385 100644
--- a/backend/helpers/pluginhelper/api/transformation_rule_helper.go
+++ b/backend/helpers/pluginhelper/api/transformation_rule_helper.go
@@ -22,7 +22,6 @@ import (
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/log"
-       "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/go-playground/validator/v10"
        "github.com/mitchellh/mapstructure"
@@ -30,11 +29,6 @@ import (
        "strconv"
 )
 
-type AbstractTr interface {
-       dal.Tabler
-       common.Model
-}
-
 // TransformationRuleHelper is used to write the CURD of transformation rule
 type TransformationRuleHelper[Tr dal.Tabler] struct {
        log       log.Logger

Reply via email to