summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-10-05 10:32:52 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-05 11:11:21 +0200
commit951abe2b2efc3a208ceea46d9c1c47d3d253ff63 (patch)
treebeb57ac3312f4c0c45285ce82d7849220e5a7cdc /app/finders
parentec8a7a36c09f44c44a21444f632389e7d08166cf (diff)
downloadgitlab-ce-951abe2b2efc3a208ceea46d9c1c47d3d253ff63.tar.gz
Load counts everywhere we render a group tree
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/group_descendants_finder.rb28
1 files changed, 2 insertions, 26 deletions
diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb
index 4e7ae6f499b..1e6523b70a2 100644
--- a/app/finders/group_descendants_finder.rb
+++ b/app/finders/group_descendants_finder.rb
@@ -3,30 +3,6 @@ class GroupDescendantsFinder
attr_reader :current_user, :parent_group, :params
- PROJECT_COUNT_SQL = <<~PROJECTCOUNT.freeze
- (SELECT COUNT(*) AS preloaded_project_count
- FROM projects
- WHERE projects.namespace_id = namespaces.id
- AND projects.archived IS NOT true)
- PROJECTCOUNT
- SUBGROUP_COUNT_SQL = <<~SUBGROUPCOUNT.freeze
- (SELECT COUNT(*) AS preloaded_subgroup_count
- FROM namespaces children
- WHERE children.parent_id = namespaces.id)
- SUBGROUPCOUNT
- MEMBER_COUNT_SQL = <<~MEMBERCOUNT.freeze
- (SELECT COUNT(*) AS preloaded_member_count
- FROM members
- WHERE members.source_type = 'Namespace'
- AND members.source_id = namespaces.id
- AND members.requested_at IS NULL)
- MEMBERCOUNT
-
- GROUP_SELECTS = ['namespaces.*',
- PROJECT_COUNT_SQL,
- SUBGROUP_COUNT_SQL,
- MEMBER_COUNT_SQL].freeze
-
def initialize(current_user: nil, parent_group:, params: {})
@current_user = current_user
@parent_group = parent_group
@@ -60,7 +36,7 @@ class GroupDescendantsFinder
end
def collections
- [subgroups.with_route.select(GROUP_SELECTS), projects]
+ [subgroups.with_selects_for_list, projects]
end
def paginator
@@ -113,7 +89,7 @@ class GroupDescendantsFinder
projects_to_load_ancestors_of = projects.where.not(namespace: parent_group)
groups_to_load_ancestors_of = Group.where(id: projects_to_load_ancestors_of.select(:namespace_id))
ancestors_for_groups(groups_to_load_ancestors_of)
- .with_route.select(GROUP_SELECTS)
+ .with_selects_for_list
end
def subgroups