summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-10-02 07:55:44 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-04 22:49:42 +0200
commitaf0b8e0558f529cd79a9dd061dc54ae3bfa9d1dd (patch)
treed43594a335fb21e6f140f4a5013e45de272ea8e7 /app/finders
parentab5d5b7ecea5d68c00171d0750b1b2f62ffbe55d (diff)
downloadgitlab-ce-af0b8e0558f529cd79a9dd061dc54ae3bfa9d1dd.tar.gz
Only preload ancestors for search results in the specified parent
When filtering we want all to preload all the ancestors upto the specified parent group. - root - subgroup - nested-group - project So when searching 'project', on the 'subgroup' page we want to preload 'nested-group' but not 'subgroup' or 'root'
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/group_descendants_finder.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb
index a39e6dedd1e..d921e59d16f 100644
--- a/app/finders/group_descendants_finder.rb
+++ b/app/finders/group_descendants_finder.rb
@@ -96,9 +96,21 @@ class GroupDescendantsFinder
.search(params[:filter])
end
+ # When filtering we want all to preload all the ancestors upto the specified
+ # parent group.
+ #
+ # - root
+ # - subgroup
+ # - nested-group
+ # - project
+ #
+ # So when searching 'project', on the 'subgroup' page we want to preload
+ # 'nested-group' but not 'subgroup' or 'root'
def ancestors_for_groups(base_for_ancestors)
+ ancestors_for_parent = Gitlab::GroupHierarchy.new(Group.where(id: parent_group))
+ .base_and_ancestors
Gitlab::GroupHierarchy.new(base_for_ancestors)
- .base_and_ancestors.where.not(id: parent_group)
+ .base_and_ancestors.where.not(id: ancestors_for_parent)
end
def subgroups