This is an automated email from the ASF dual-hosted git repository.
likyh 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 be38207d4 fix(framework): update project mapping (#3972)
be38207d4 is described below
commit be38207d4b24d991673682f5b200e9a447512ad9
Author: Warren Chen <[email protected]>
AuthorDate: Tue Dec 20 14:08:19 2022 +0800
fix(framework): update project mapping (#3972)
---
services/blueprint_makeplan_v200.go | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/services/blueprint_makeplan_v200.go
b/services/blueprint_makeplan_v200.go
index 607b258f5..904d6ef6f 100644
--- a/services/blueprint_makeplan_v200.go
+++ b/services/blueprint_makeplan_v200.go
@@ -20,11 +20,11 @@ package services
import (
"encoding/json"
"fmt"
-
"github.com/apache/incubator-devlake/errors"
"github.com/apache/incubator-devlake/models"
"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
"github.com/apache/incubator-devlake/plugins/core"
+ "github.com/apache/incubator-devlake/plugins/core/dal"
)
// GeneratePlanJsonV200 generates pipeline plan according v2.0.0 definition
@@ -41,12 +41,6 @@ func GeneratePlanJsonV200(
}
// refresh project_mapping table to reflect project/scopes relationship
if len(scopes) > 0 {
- if projectName != "" {
- e := db.Where("project_name = ?",
projectName).Delete(&crossdomain.ProjectMapping{}).Error
- if e != nil {
- return nil, errors.Default.Wrap(e,
fmt.Sprintf("projectName:[%s]", projectName))
- }
- }
for _, scope := range scopes {
e := basicRes.GetDal().CreateOrUpdate(scope)
if e != nil {
@@ -55,6 +49,23 @@ func GeneratePlanJsonV200(
}
}
}
+ if len(projectName) != 0 {
+ err = basicRes.GetDal().Delete(&crossdomain.ProjectMapping{},
dal.Where("project_name = ?", projectName))
+ if err != nil {
+ return nil, err
+ }
+ for _, scope := range scopes {
+ projectMapping := &crossdomain.ProjectMapping{
+ ProjectName: projectName,
+ Table: scope.TableName(),
+ RowId: scope.ScopeId(),
+ }
+ err = basicRes.GetDal().CreateIfNotExist(projectMapping)
+ if err != nil {
+ return nil, err
+ }
+ }
+ }
return plan, err
}
@@ -93,7 +104,7 @@ func genPlanJsonV200(
if err != nil {
return nil, nil, err
}
- // collect scopes for the project. a github repository
may produces
+ // collect scopes for the project. a github repository
may produce
// 2 scopes, 1 repo and 1 board
scopes = append(scopes, pluginScopes...)
} else {