abeizn commented on code in PR #6146:
URL: 
https://github.com/apache/incubator-devlake/pull/6146#discussion_r1339428062


##########
backend/plugins/github/api/init.go:
##########
@@ -18,69 +18,44 @@ limitations under the License.
 package api
 
 import (
-       "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"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+       "github.com/apache/incubator-devlake/helpers/srvhelper"
        "github.com/apache/incubator-devlake/plugins/github/models"
        "github.com/go-playground/validator/v10"
 )
 
 var vld *validator.Validate
+
+// var connSrv *srvhelper.ConnectionSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var connApi *api.DsConnectionApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scopeSrv *srvhelper.ScopeSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scopeApi *api.DsScopeApiHelper[models.GithubConnection, models.GithubRepo, 
models.GithubScopeConfig]
+var scSrv *srvhelper.ScopeConfigSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scApi *api.DsScopeConfigApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
 var connectionHelper *api.ConnectionApiHelper
-var scopeHelper *api.ScopeApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
 var basicRes context.BasicRes
-var scHelper *api.ScopeConfigHelper[models.GithubScopeConfig]
 var remoteHelper *api.RemoteApiHelper[models.GithubConnection, 
models.GithubRepo, repo, plugin.ApiGroup]
 
 func Init(br context.BasicRes, p plugin.PluginMeta) {
-
        basicRes = br
+       _, connApi, scopeSrv, scopeApi, scSrv, scApi = api.NewDataSourceHelpers[
+               models.GithubConnection,
+               models.GithubRepo, models.GithubScopeConfig,
+       ](
+               br,
+               "github",
+               []string{"full_name"},
+       )
+       // TODO: refactor remoteHelper
        vld = validator.New()
        connectionHelper = api.NewConnectionHelper(
                basicRes,
                vld,
                p.Name(),
        )
-       params := &api.ReflectionParameters{
-               ScopeIdFieldName:     "GithubId",
-               ScopeIdColumnName:    "github_id",
-               RawScopeParamName:    "Name",
-               SearchScopeParamName: "name",

Review Comment:
   
![image](https://github.com/apache/incubator-devlake/assets/101256042/a05730e8-9865-4994-9ccb-4c6b2f3c0cb1)
   
   Strangely, shouldn't this be ‘name’, not ‘full_name’?



##########
backend/plugins/github/api/init.go:
##########
@@ -18,69 +18,44 @@ limitations under the License.
 package api
 
 import (
-       "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"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+       "github.com/apache/incubator-devlake/helpers/srvhelper"
        "github.com/apache/incubator-devlake/plugins/github/models"
        "github.com/go-playground/validator/v10"
 )
 
 var vld *validator.Validate
+
+// var connSrv *srvhelper.ConnectionSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var connApi *api.DsConnectionApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scopeSrv *srvhelper.ScopeSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scopeApi *api.DsScopeApiHelper[models.GithubConnection, models.GithubRepo, 
models.GithubScopeConfig]
+var scSrv *srvhelper.ScopeConfigSrvHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
+var scApi *api.DsScopeConfigApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
 var connectionHelper *api.ConnectionApiHelper
-var scopeHelper *api.ScopeApiHelper[models.GithubConnection, 
models.GithubRepo, models.GithubScopeConfig]
 var basicRes context.BasicRes
-var scHelper *api.ScopeConfigHelper[models.GithubScopeConfig]
 var remoteHelper *api.RemoteApiHelper[models.GithubConnection, 
models.GithubRepo, repo, plugin.ApiGroup]
 
 func Init(br context.BasicRes, p plugin.PluginMeta) {
-
        basicRes = br
+       _, connApi, scopeSrv, scopeApi, scSrv, scApi = api.NewDataSourceHelpers[
+               models.GithubConnection,
+               models.GithubRepo, models.GithubScopeConfig,
+       ](
+               br,
+               "github",
+               []string{"full_name"},
+       )
+       // TODO: refactor remoteHelper
        vld = validator.New()
        connectionHelper = api.NewConnectionHelper(
                basicRes,
                vld,
                p.Name(),
        )
-       params := &api.ReflectionParameters{
-               ScopeIdFieldName:     "GithubId",
-               ScopeIdColumnName:    "github_id",
-               RawScopeParamName:    "Name",
-               SearchScopeParamName: "name",

Review Comment:
   
![image](https://github.com/apache/incubator-devlake/assets/101256042/a05730e8-9865-4994-9ccb-4c6b2f3c0cb1)
   
   Strangely, shouldn't this be ‘name’, not ‘full_name’?



-- 
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-unsubscr...@devlake.apache.org

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

Reply via email to