You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "mappjzc (via GitHub)" <gi...@apache.org> on 2023/05/22 15:46:27 UTC

[GitHub] [incubator-devlake] mappjzc opened a new pull request, #5257: Zentao changelog

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

   ### Summary
   Add Dbget to zentao for changelog.
   Dbget will get the data directly from databases.
   
   ### Screenshots
   ![image](https://github.com/apache/incubator-devlake/assets/2921251/2d772113-6f2d-4413-aa73-1bf60145d2a7)
   


-- 
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] klesh commented on a diff in pull request #5257: Zentao changelog

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #5257:
URL: https://github.com/apache/incubator-devlake/pull/5257#discussion_r1204913668


##########
backend/plugins/zentao/api/blueprint_V200_test.go:
##########
@@ -82,9 +82,14 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
 				Plugin:   "zentao",
 				Subtasks: []string{},
 				Options: map[string]interface{}{
-					"ConnectionId": uint64(1),
-					"productId":    int64(0),
-					"projectId":    int64(1),
+					"ConnectionId":   uint64(1),
+					"productId":      int64(0),
+					"projectId":      int64(1),
+					"RemoteDb":       nil,

Review Comment:
   No necessary



##########
backend/plugins/zentao/api/blueprint_V200_test.go:
##########
@@ -93,9 +98,14 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
 				Plugin:   "zentao",
 				Subtasks: []string{},
 				Options: map[string]interface{}{
-					"ConnectionId": uint64(1),
-					"productId":    int64(1),
-					"projectId":    int64(0),
+					"ConnectionId":   uint64(1),
+					"productId":      int64(1),
+					"projectId":      int64(0),
+					"RemoteDb":       nil,

Review Comment:
   Same as above



##########
backend/plugins/zentao/api/blueprint_v200.go:
##########
@@ -81,6 +82,7 @@ func makePipelinePlanV200(
 				return nil, nil, errors.Default.Wrap(err, fmt.Sprintf("fail to find zentao project %s", bpScope.Id))
 			}
 			op.ProjectId = scope.Id
+			op.DbUrl = connection.DbUrl

Review Comment:
   Either we put all db connection settings into the `Connection` object or `TaskData`.
   Placing them both places create unnecessary complex.
   
   I think putting them into `Connection` makes more sense.



-- 
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] klesh commented on a diff in pull request #5257: Zentao changelog

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #5257:
URL: https://github.com/apache/incubator-devlake/pull/5257#discussion_r1205423284


##########
backend/plugins/zentao/tasks/changelog_dbget.go:
##########
@@ -0,0 +1,122 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+	"fmt"
+	"reflect"
+
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/plugin"
+	"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/zentao/models"
+)
+
+var _ plugin.SubTaskEntryPoint = DBGetActionHistory
+
+func DBGetActionHistory(taskCtx plugin.SubTaskContext) errors.Error {
+	data := taskCtx.GetData().(*ZentaoTaskData)
+
+	// skip if no RemoteDb
+	if data.RemoteDb == nil {
+		return nil
+	}
+
+	divider := api.NewBatchSaveDivider(taskCtx, 500, "", "")
+	defer func() {
+		err1 := divider.Close()
+		if err1 != nil {
+			panic(err1)
+		}
+	}()
+
+	return dBGetActionHistory(data, func(zcc *models.ZentaoChangelogCom) errors.Error {
+		batch, err := divider.ForType(reflect.TypeOf(zcc.Changelog))
+		if err != nil {
+			return err
+		}
+		zcc.Changelog.ConnectionId = data.Options.ConnectionId
+		zcc.Changelog.Product = int(data.Options.ProductId)
+		err = batch.Add(zcc.Changelog)
+		if err != nil {
+			return err
+		}
+		if zcc.ChangelogDetail.Id != 0 {
+			batch, err = divider.ForType(reflect.TypeOf(zcc.ChangelogDetail))
+			if err != nil {
+				return err
+			}
+			zcc.ChangelogDetail.ConnectionId = data.Options.ConnectionId
+			err = batch.Add(zcc.ChangelogDetail)
+			if err != nil {
+				return err
+			}
+		}
+		return nil
+	})
+}
+
+var DBGetChangelogMeta = plugin.SubTaskMeta{
+	Name:             "DBGetChangelog",
+	EntryPoint:       DBGetActionHistory,
+	EnabledByDefault: true,
+	Description:      "get action and history data to be changelog from Zentao databases",
+	DomainTypes:      []string{plugin.DOMAIN_TYPE_TICKET},
+}
+
+// it is work for zentao version 18.3
+func dBGetActionHistory(data *ZentaoTaskData, callback func(*models.ZentaoChangelogCom) errors.Error) errors.Error {

Review Comment:
   Why creating a function which used once?



-- 
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] klesh merged pull request #5257: Zentao changelog

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh merged PR #5257:
URL: https://github.com/apache/incubator-devlake/pull/5257


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