From fe43a27b1fdcddc28600b87581672b4451fc7407 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Mon, 7 Oct 2019 10:08:05 +0200
Subject: [PATCH] The new BLOCK_SIZE field now can be loaded via a new function
 in the duplicatescanner lib. This has been integrated into the action to
 rebuild person and org duplicates

---
 .../onActionProcess.js                           |  2 +-
 .../onActionProcess.js                           |  2 +-
 process/DuplicateScanner_lib/process.js          | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildorganisationduplicatescache/onActionProcess.js b/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildorganisationduplicatescache/onActionProcess.js
index 811f26d0b3..61251284d2 100644
--- a/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildorganisationduplicatescache/onActionProcess.js
+++ b/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildorganisationduplicatescache/onActionProcess.js
@@ -3,7 +3,7 @@ import("DuplicateScanner_lib");
 
 var filterName = "OrganisationDuplicates";
 var targetEntity = "Organisation_entity";
-var recordBlockSize = 500;
+var recordBlockSize = DuplicateScannerUtils.GetBlockSizeForScanner(filterName, targetEntity);
 let duplicateFieldsConfig = DuplicateScannerUtils.LoadIndexFieldsConfiguration(filterName, targetEntity);
 let resultFields = DuplicateScannerUtils.LoadResultFields(filterName, targetEntity);
 
diff --git a/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildpersonduplicatescache/onActionProcess.js b/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildpersonduplicatescache/onActionProcess.js
index 155fee2cdc..45556e0b71 100644
--- a/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildpersonduplicatescache/onActionProcess.js
+++ b/entity/DuplicateScanner_entity/entityfields/runactiongroup/children/rebuildpersonduplicatescache/onActionProcess.js
@@ -3,7 +3,7 @@ import("DuplicateScanner_lib");
 
 var filterName = "PersonDuplicates";
 var targetEntity = "Person_entity";
-var recordBlockSize = 500;
+var recordBlockSize = DuplicateScannerUtils.GetBlockSizeForScanner(filterName, targetEntity);
 let duplicateFieldsConfig = DuplicateScannerUtils.LoadIndexFieldsConfiguration(filterName, targetEntity);
 let resultFields = DuplicateScannerUtils.LoadResultFields(filterName, targetEntity);
 
diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index c89c0e2b40..c9e8a0da62 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -466,6 +466,22 @@ DuplicateScannerUtils.CacheNewScanResults = function(pNewRecordId, pDuplicateIds
     return db.inserts(insertQueriesRay);
 }
 
+/* 
+ * Loads the configured block size for the specified scanner
+ * 
+ * @param {String} pFilterName Name of the filter to use
+ * @param {String} pTargetEntity The target entity which has been assigned to the filters configuration
+ * @returns {Integer} Blocksize of the specified scanner
+ */
+DuplicateScannerUtils.GetBlockSizeForScanner = function(pFilterName, pTargetEntity)
+{
+    let blockSizeCondition = SqlCondition.begin()
+                                         .andPrepare("DUPLICATESCANNER.FILTER_NAME", pFilterName)
+                                         .andPrepare("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity)
+                                         .buildSql("select BLOCK_SIZE from DUPLICATESCANNER");
+    return db.cell(blockSizeCondition);
+}
+
 /* 
  * Searches for a cluster which contains the duplicates specified by the parameterized array. <br />
  * The contents of the cluster have to be identical, if no fitting cluster could be found an empty string is returned.
-- 
GitLab