Skip to content
Snippets Groups Projects

Replace Group ancestors scope with linear version

All threads resolved!
3 files
+ 37
11
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 10
4
@@ -192,9 +192,15 @@ def preset_root_ancestor_for(groups)
# Returns the ids of the passed group models where the `emails_disabled`
# column is set to true anywhere in the ancestor hierarchy.
def ids_with_disabled_email(groups)
innner_query = Gitlab::ObjectHierarchy
.new(Group.where('id = namespaces_with_emails_disabled.id'))
.base_and_ancestors
inner_groups = Group.where('id = namespaces_with_emails_disabled.id')
inner_ancestors = if Feature.enabled?(:linear_group_ancestor_scopes, default_enabled: :yaml)
inner_groups.self_and_ancestors
else
Gitlab::ObjectHierarchy.new(inner_groups).base_and_ancestors
end
inner_query = inner_ancestors
.where(emails_disabled: true)
.select('1')
.limit(1)
@@ -202,7 +208,7 @@ def ids_with_disabled_email(groups)
group_ids = Namespace
.from('(SELECT * FROM namespaces) as namespaces_with_emails_disabled')
.where(namespaces_with_emails_disabled: { id: groups })
.where('EXISTS (?)', innner_query)
.where('EXISTS (?)', inner_query)
.pluck(:id)
Set.new(group_ids)
Loading