diff options
Diffstat (limited to 'app/finders/concerns/finder_with_group_hierarchy.rb')
-rw-r--r-- | app/finders/concerns/finder_with_group_hierarchy.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/finders/concerns/finder_with_group_hierarchy.rb b/app/finders/concerns/finder_with_group_hierarchy.rb index 86ccac19b63..4ced544ba2c 100644 --- a/app/finders/concerns/finder_with_group_hierarchy.rb +++ b/app/finders/concerns/finder_with_group_hierarchy.rb @@ -27,6 +27,12 @@ module FinderWithGroupHierarchy # we can preset root group for all of them to optimize permission checks Group.preset_root_ancestor_for(groups) + # Preloading the max access level for the given groups to avoid N+1 queries + # during the access check. + if !skip_authorization && current_user && Feature.enabled?(:preload_max_access_levels_for_labels_finder, group) + Preloaders::UserMaxAccessLevelInGroupsPreloader.new(groups, current_user).execute + end + groups_user_can_read_items(groups).map(&:id) end end |