Просмотр исходного кода

Merge branch 'imprv/user-group-delete' into imprv/user-group-relation-crud

Taichi Masuyama 4 лет назад
Родитель
Сommit
bf80399dca
1 измененных файлов с 10 добавлено и 10 удалено
  1. 10 10
      packages/app/src/server/models/user-group.js

+ 10 - 10
packages/app/src/server/models/user-group.js

@@ -97,16 +97,6 @@ class UserGroup {
     };
   }
 
-  static async findGroupsWithDescendantsRecursively(groups, descendants = groups) {
-    const nextGroups = await this.find({ parent: { $in: groups.map(g => g._id) } });
-
-    if (nextGroups.length === 0) {
-      return descendants;
-    }
-
-    return this.findAllAncestorGroups(nextGroups, descendants.concat(nextGroups));
-  }
-
   // Delete completely
   static async removeCompletelyByRootGroupId(deleteRootGroupId, action, transferToUserGroupId, user) {
     const UserGroupRelation = mongoose.model('UserGroupRelation');
@@ -161,6 +151,16 @@ class UserGroup {
     return this.findAllAncestorGroups(nextParent, ancestors);
   }
 
+  static async findGroupsWithDescendantsRecursively(groups, descendants = groups) {
+    const nextGroups = await this.find({ parent: { $in: groups.map(g => g._id) } });
+
+    if (nextGroups.length === 0) {
+      return descendants;
+    }
+
+    return this.findGroupsWithDescendantsRecursively(nextGroups, descendants.concat(nextGroups));
+  }
+
   // TODO 85062: write test code
   static async updateGroup(id, name, description, parentId, forceUpdateParents = false) {
     const userGroup = await this.findById(id);