You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/11/09 09:45:34 UTC

(incubator-devlake) branch main updated: fix(org): save project mappings in small batch (#6335)

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

abeizn 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 f6b04385f fix(org): save project mappings in small batch (#6335)
f6b04385f is described below

commit f6b04385fe4ec34acb248899b61149e66dd96d0b
Author: Lynwee <li...@merico.dev>
AuthorDate: Thu Nov 9 17:45:29 2023 +0800

    fix(org): save project mappings in small batch (#6335)
---
 backend/plugins/org/tasks/project_mapping.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/backend/plugins/org/tasks/project_mapping.go b/backend/plugins/org/tasks/project_mapping.go
index 4af980710..ede6fc834 100644
--- a/backend/plugins/org/tasks/project_mapping.go
+++ b/backend/plugins/org/tasks/project_mapping.go
@@ -25,6 +25,8 @@ import (
 	"github.com/apache/incubator-devlake/core/plugin"
 )
 
+const DefaultBatchSize = 100
+
 var SetProjectMappingMeta = plugin.SubTaskMeta{
 	Name:             "setProjectMapping",
 	EntryPoint:       SetProjectMapping,
@@ -57,6 +59,12 @@ func SetProjectMapping(taskCtx plugin.SubTaskContext) errors.Error {
 					},
 				},
 			})
+			if len(projectMappings) == DefaultBatchSize {
+				if err := db.CreateOrUpdate(projectMappings); err != nil {
+					return err
+				}
+				projectMappings = []crossdomain.ProjectMapping{}
+			}
 		}
 		if len(projectMappings) > 0 {
 			err = db.CreateOrUpdate(projectMappings)