You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2023/08/10 06:53:21 UTC
[incubator-devlake] branch main updated: fix: data scope search in blueprints (#5844)
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 5046993b8 fix: data scope search in blueprints (#5844)
5046993b8 is described below
commit 5046993b8d05952532ce7a7fa01426d49a985319
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Aug 10 14:53:16 2023 +0800
fix: data scope search in blueprints (#5844)
* fix: data scope search in blueprints
* fix: update the field
---
backend/helpers/pluginhelper/api/scope_db_helper.go | 8 ++------
backend/plugins/bamboo/api/init.go | 7 ++++---
backend/plugins/bitbucket/api/init.go | 7 ++++---
backend/plugins/github/api/init.go | 10 ++++++----
backend/plugins/gitlab/api/init.go | 2 +-
backend/plugins/jenkins/api/init.go | 7 ++++---
backend/plugins/jira/api/init.go | 7 ++++---
backend/plugins/pagerduty/api/init.go | 7 ++++---
backend/plugins/sonarqube/api/init.go | 7 ++++---
backend/plugins/tapd/api/init.go | 7 ++++---
backend/plugins/zentao/api/init.go | 7 ++++---
11 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/scope_db_helper.go b/backend/helpers/pluginhelper/api/scope_db_helper.go
index 8fc6506ab..08b14cea4 100644
--- a/backend/helpers/pluginhelper/api/scope_db_helper.go
+++ b/backend/helpers/pluginhelper/api/scope_db_helper.go
@@ -115,12 +115,8 @@ func (s *ScopeDatabaseHelperImpl[Conn, Scope, Tr]) GetScopeAndConfig(connectionI
func (s *ScopeDatabaseHelperImpl[Conn, Scope, Tr]) ListScopes(input *plugin.ApiResourceInput, connectionId uint64) ([]*Scope, errors.Error) {
searchTerm := input.Query.Get("searchTerm")
query := dal.Where("connection_id = ?", connectionId)
- if searchTerm != "" {
- if s.params.SearchScopeParamName != "" {
- query = dal.Where(fmt.Sprintf("connection_id = ? AND %s LIKE ?", s.params.SearchScopeParamName), connectionId, "%"+searchTerm+"%")
- } else {
- query = dal.Where(fmt.Sprintf("connection_id = ? AND %s LIKE ?", s.params.RawScopeParamName), connectionId, "%"+searchTerm+"%")
- }
+ if searchTerm != "" && s.params.SearchScopeParamName != "" {
+ query = dal.Where(fmt.Sprintf("connection_id = ? AND %s LIKE ?", s.params.SearchScopeParamName), connectionId, "%"+searchTerm+"%")
}
limit, offset := GetLimitOffset(input.Query, "pageSize", "page")
var scopes []*Scope
diff --git a/backend/plugins/bamboo/api/init.go b/backend/plugins/bamboo/api/init.go
index 91b151f45..47eec3408 100644
--- a/backend/plugins/bamboo/api/init.go
+++ b/backend/plugins/bamboo/api/init.go
@@ -43,9 +43,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "PlanKey",
- ScopeIdColumnName: "plan_key",
- RawScopeParamName: "PlanKey",
+ ScopeIdFieldName: "PlanKey",
+ ScopeIdColumnName: "plan_key",
+ RawScopeParamName: "PlanKey",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.BambooConnection, models.BambooPlan, models.BambooScopeConfig](
basicRes,
diff --git a/backend/plugins/bitbucket/api/init.go b/backend/plugins/bitbucket/api/init.go
index dbdf77b0b..349522473 100644
--- a/backend/plugins/bitbucket/api/init.go
+++ b/backend/plugins/bitbucket/api/init.go
@@ -42,9 +42,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "BitbucketId",
- ScopeIdColumnName: "bitbucket_id",
- RawScopeParamName: "FullName",
+ ScopeIdFieldName: "BitbucketId",
+ ScopeIdColumnName: "bitbucket_id",
+ RawScopeParamName: "FullName",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.BitbucketConnection, models.BitbucketRepo, models.BitbucketScopeConfig](
basicRes,
diff --git a/backend/plugins/github/api/init.go b/backend/plugins/github/api/init.go
index 53877f920..2459b86d0 100644
--- a/backend/plugins/github/api/init.go
+++ b/backend/plugins/github/api/init.go
@@ -18,9 +18,10 @@ limitations under the License.
package api
import (
- "github.com/apache/incubator-devlake/core/plugin"
"strconv"
+ "github.com/apache/incubator-devlake/core/plugin"
+
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
@@ -46,9 +47,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "GithubId",
- ScopeIdColumnName: "github_id",
- RawScopeParamName: "Name",
+ ScopeIdFieldName: "GithubId",
+ ScopeIdColumnName: "github_id",
+ RawScopeParamName: "Name",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.GithubConnection, models.GithubRepo, models.GithubScopeConfig](
basicRes,
diff --git a/backend/plugins/gitlab/api/init.go b/backend/plugins/gitlab/api/init.go
index 06f3f9de9..3637c03d1 100644
--- a/backend/plugins/gitlab/api/init.go
+++ b/backend/plugins/gitlab/api/init.go
@@ -45,7 +45,7 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
ScopeIdFieldName: "GitlabId",
ScopeIdColumnName: "gitlab_id",
RawScopeParamName: "ProjectId",
- SearchScopeParamName: "Name",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.GitlabConnection, models.GitlabProject, models.GitlabScopeConfig](
basicRes,
diff --git a/backend/plugins/jenkins/api/init.go b/backend/plugins/jenkins/api/init.go
index d36b7f80e..ef3ccc2ae 100644
--- a/backend/plugins/jenkins/api/init.go
+++ b/backend/plugins/jenkins/api/init.go
@@ -43,9 +43,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "FullName",
- ScopeIdColumnName: "full_name",
- RawScopeParamName: "FullName",
+ ScopeIdFieldName: "FullName",
+ ScopeIdColumnName: "full_name",
+ RawScopeParamName: "FullName",
+ SearchScopeParamName: "full_name",
}
scopeHelper = api.NewScopeHelper[models.JenkinsConnection, models.JenkinsJob, models.JenkinsScopeConfig](
basicRes,
diff --git a/backend/plugins/jira/api/init.go b/backend/plugins/jira/api/init.go
index 22143ef45..ebb7b15fa 100644
--- a/backend/plugins/jira/api/init.go
+++ b/backend/plugins/jira/api/init.go
@@ -43,9 +43,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "BoardId",
- ScopeIdColumnName: "board_id",
- RawScopeParamName: "BoardId",
+ ScopeIdFieldName: "BoardId",
+ ScopeIdColumnName: "board_id",
+ RawScopeParamName: "BoardId",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.JiraConnection, models.JiraBoard, models.JiraScopeConfig](
basicRes,
diff --git a/backend/plugins/pagerduty/api/init.go b/backend/plugins/pagerduty/api/init.go
index eeacbc794..5c521e843 100644
--- a/backend/plugins/pagerduty/api/init.go
+++ b/backend/plugins/pagerduty/api/init.go
@@ -42,9 +42,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "Id",
- ScopeIdColumnName: "id",
- RawScopeParamName: "ScopeId",
+ ScopeIdFieldName: "Id",
+ ScopeIdColumnName: "id",
+ RawScopeParamName: "ScopeId",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.PagerDutyConnection, models.Service, models.PagerdutyScopeConfig](
basicRes,
diff --git a/backend/plugins/sonarqube/api/init.go b/backend/plugins/sonarqube/api/init.go
index 52979f941..3ad87a245 100644
--- a/backend/plugins/sonarqube/api/init.go
+++ b/backend/plugins/sonarqube/api/init.go
@@ -41,9 +41,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "ProjectKey",
- ScopeIdColumnName: "project_key",
- RawScopeParamName: "ProjectKey",
+ ScopeIdFieldName: "ProjectKey",
+ ScopeIdColumnName: "project_key",
+ RawScopeParamName: "ProjectKey",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.SonarqubeConnection, models.SonarqubeProject, any](
basicRes,
diff --git a/backend/plugins/tapd/api/init.go b/backend/plugins/tapd/api/init.go
index 559acd70b..ec2024de1 100644
--- a/backend/plugins/tapd/api/init.go
+++ b/backend/plugins/tapd/api/init.go
@@ -42,9 +42,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
p.Name(),
)
params := &api.ReflectionParameters{
- ScopeIdFieldName: "Id",
- ScopeIdColumnName: "id",
- RawScopeParamName: "WorkSpaceId",
+ ScopeIdFieldName: "Id",
+ ScopeIdColumnName: "id",
+ RawScopeParamName: "WorkSpaceId",
+ SearchScopeParamName: "name",
}
scopeHelper = api.NewScopeHelper[models.TapdConnection, models.TapdWorkspace, models.TapdScopeConfig](
basicRes,
diff --git a/backend/plugins/zentao/api/init.go b/backend/plugins/zentao/api/init.go
index 2e7abfd49..70db069a3 100644
--- a/backend/plugins/zentao/api/init.go
+++ b/backend/plugins/zentao/api/init.go
@@ -49,9 +49,10 @@ func Init(br context.BasicRes, p plugin.PluginMeta) {
)
projectParams := &api.ReflectionParameters{
- ScopeIdFieldName: "Id",
- ScopeIdColumnName: "id",
- RawScopeParamName: "ProjectId",
+ ScopeIdFieldName: "Id",
+ ScopeIdColumnName: "id",
+ RawScopeParamName: "ProjectId",
+ SearchScopeParamName: "name",
}
projectScopeHelper = api.NewScopeHelper[models.ZentaoConnection, models.ZentaoProject, models.ZentaoScopeConfig](
basicRes,