Sfoglia il codice sorgente

change batch size variable name

Futa Arai 2 anni fa
parent
commit
ee72f4e4bf

+ 5 - 5
apps/app/src/features/external-user-group/server/service/external-user-group-sync.ts

@@ -13,9 +13,9 @@ import ExternalUserGroupRelation from '../models/external-user-group-relation';
 
 // When d = max depth of group trees
 // Max space complexity of syncExternalUserGroups will be:
-// O(MAX_TREES_TO_PROCESS * d * MAX_USERS_TO_PROCESS)
-const MAX_TREES_TO_PROCESS = 10;
-const MAX_USERS_TO_PROCESS = 100;
+// O(TREES_BATCH_SIZE * d * USERS_BATCH_SIZE)
+const TREES_BATCH_SIZE = 10;
+const USERS_BATCH_SIZE = 100;
 
 abstract class ExternalUserGroupSyncService {
 
@@ -48,7 +48,7 @@ abstract class ExternalUserGroupSyncService {
       }
     };
 
-    await batchProcessPromiseAll(trees, MAX_TREES_TO_PROCESS, (root) => {
+    await batchProcessPromiseAll(trees, TREES_BATCH_SIZE, (root) => {
       return syncNode(root);
     });
 
@@ -71,7 +71,7 @@ abstract class ExternalUserGroupSyncService {
     const externalUserGroup = await ExternalUserGroup.findAndUpdateOrCreateGroup(
       node.name, node.id, this.groupProviderType, node.description, parentId,
     );
-    await batchProcessPromiseAll(node.userInfos, MAX_USERS_TO_PROCESS, async(userInfo) => {
+    await batchProcessPromiseAll(node.userInfos, USERS_BATCH_SIZE, async(userInfo) => {
       const user = await this.getMemberUser(userInfo);
 
       if (user != null) {

+ 5 - 5
apps/app/src/features/external-user-group/server/service/ldap-user-group-sync.ts

@@ -11,9 +11,9 @@ import ExternalUserGroupSyncService from './external-user-group-sync';
 
 // When d = max depth of group trees
 // Max space complexity of generateExternalUserGroupTrees will be:
-// O(MAX_TREES_TO_PROCESS * d * MAX_USERS_TO_PROCESS)
-const MAX_TREES_TO_PROCESS = 10;
-const MAX_USERS_TO_PROCESS = 100;
+// O(TREES_BATCH_SIZE * d * USERS_BATCH_SIZE)
+const TREES_BATCH_SIZE = 10;
+const USERS_BATCH_SIZE = 100;
 
 class LdapUserGroupSyncService extends ExternalUserGroupSyncService {
 
@@ -62,7 +62,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService {
 
       const userIds = getUserIdsFromGroupEntry(entry);
 
-      const userInfos = (await batchProcessPromiseAll(userIds, MAX_USERS_TO_PROCESS, (id) => {
+      const userInfos = (await batchProcessPromiseAll(userIds, USERS_BATCH_SIZE, (id) => {
         return this.getUserInfo(id);
       })).filter((info): info is NonNullable<ExternalUserInfo> => info != null);
       const name = this.ldapService.getStringValFromSearchResultEntry(entry, groupNameAttribute);
@@ -98,7 +98,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService {
       return !allChildGroupDNs.has(entry.objectName);
     });
 
-    return (await batchProcessPromiseAll(rootEntries, MAX_TREES_TO_PROCESS, entry => convert(entry, [])))
+    return (await batchProcessPromiseAll(rootEntries, TREES_BATCH_SIZE, entry => convert(entry, [])))
       .filter((node): node is NonNullable<ExternalUserGroupTreeNode> => node != null);
   }