Commit db3e5019 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '37748-clean-up-optimized_groups_user_can_read_epics_method-ff' into 'master'

Optimize Group#for_epics scope

Closes #37368 and #37748

See merge request gitlab-org/gitlab!22375
parents 6471188f 061ecda5
......@@ -75,12 +75,8 @@ module EE
end
scope :for_epics, ->(epics) do
if ::Feature.enabled?(:optimized_groups_user_can_read_epics_method)
epics_query = epics.select(:group_id)
joins("INNER JOIN (#{epics_query.to_sql}) as epics on epics.group_id = namespaces.id")
else
where(id: epics.select(:group_id))
end
end
state_machine :ldap_sync_status, namespace: :ldap_sync, initial: :ready do
......
---
title: Optimize Group#for_epics scope
merge_request: 22375
author:
type: performance
......@@ -77,31 +77,11 @@ describe Group do
let_it_be(:epic1) { create(:epic) }
let_it_be(:epic2) { create(:epic) }
shared_examples '.for_epics examples' do
it 'returns groups only for selected epics' do
epics = ::Epic.where(id: epic1)
expect(described_class.for_epics(epics)).to contain_exactly(epic1.group)
end
end
context 'with `optimized_groups_user_can_read_epics_method` feature flag' do
before do
stub_feature_flags(optimized_groups_user_can_read_epics_method: flag_state)
end
context 'enabled' do
let(:flag_state) { true }
include_examples '.for_epics examples'
end
context 'disabled' do
let(:flag_state) { false }
include_examples '.for_epics examples'
end
end
end
end
describe 'validations' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment