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 <[email protected]>
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)

Reply via email to