Commit 7e19d4ff authored by Sean McGivern's avatar Sean McGivern

Merge branch 'remove-optimize_deploy_keys_presenter-feature-flag' into 'master'

Remove `optimize_deploy_keys_presenter` feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57551
parents 6f90a234 8d12d7a8
...@@ -42,17 +42,8 @@ module Projects ...@@ -42,17 +42,8 @@ module Projects
# It excludes: # It excludes:
# - The deploy keys enabled in the project # - The deploy keys enabled in the project
def available_project_keys def available_project_keys
if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml) strong_memoize(:available_project_keys) do
strong_memoize(:available_project_keys) do current_user.project_deploy_keys.with_projects - enabled_keys
current_user.project_deploy_keys.with_projects - enabled_keys
end
else
strong_memoize(:legacy_available_project_keys) do
current_user
.project_deploy_keys
.id_not_in(enabled_keys.select(:id))
.with_projects
end
end end
end end
...@@ -61,22 +52,8 @@ module Projects ...@@ -61,22 +52,8 @@ module Projects
# It excludes: # It excludes:
# - The deploy keys enabled in the project. # - The deploy keys enabled in the project.
def available_public_keys def available_public_keys
if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml) strong_memoize(:available_public_keys) do
strong_memoize(:available_public_keys) do DeployKey.are_public.with_projects - enabled_keys
DeployKey.are_public.with_projects - enabled_keys
end
else
strong_memoize(:legacy_available_public_keys) do
# This also excludes "Enabled deploy keys in projects that can be accessed by the user".
# However, this means we are filtering out a public key that enabled
# in the other project, which should be also available for this project.
# We should expose the public keys that has not been enabled on the project yet.
DeployKey
.are_public
.id_not_in(enabled_keys.select(:id))
.id_not_in(available_project_keys.select(:id))
.with_projects
end
end end
end end
...@@ -110,17 +87,10 @@ module Projects ...@@ -110,17 +87,10 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def user_readable_project_ids def user_readable_project_ids
project_ids = if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml) project_ids = (available_project_keys + available_public_keys)
(available_project_keys + available_public_keys) .flat_map { |deploy_key| deploy_key.deploy_keys_projects.map(&:project_id) }
.flat_map { |deploy_key| deploy_key.deploy_keys_projects.map(&:project_id) } .compact
.compact .uniq
.uniq
else
(available_keys + available_project_keys + available_public_keys)
.flat_map { |deploy_key| deploy_key.deploy_keys_projects.map(&:project_id) }
.compact
.uniq
end
current_user.authorized_projects(Gitlab::Access::GUEST).id_in(project_ids).pluck(:id) current_user.authorized_projects(Gitlab::Access::GUEST).id_in(project_ids).pluck(:id)
end end
......
---
title: Optimize Deploy Keys Presenter
merge_request: 57551
author:
type: performance
---
name: optimize_deploy_keys_presenter
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56305/diffs
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/324143
milestone: '13.10'
type: development
group: group::release
default_enabled: false
...@@ -27,43 +27,31 @@ RSpec.describe Projects::Settings::DeployKeysPresenter do ...@@ -27,43 +27,31 @@ RSpec.describe Projects::Settings::DeployKeysPresenter do
let_it_be(:unrelated_project) { create(:project, :private) } let_it_be(:unrelated_project) { create(:project, :private) }
let_it_be(:unrelated_deploy_key) { create(:deploy_key, projects: [unrelated_project]) } let_it_be(:unrelated_deploy_key) { create(:deploy_key, projects: [unrelated_project]) }
shared_examples_for 'correct behavior' do context 'with enabled keys' do
context 'with enabled keys' do it 'returns correct deploy keys' do
it 'returns correct deploy keys' do expect(presenter.enabled_keys).to eq([deploy_key])
expect(presenter.enabled_keys).to eq([deploy_key]) expect(presenter.enabled_keys_size).to eq(1)
expect(presenter.enabled_keys_size).to eq(1)
end
end
context 'with available keys' do
it 'returns correct deploy keys' do
expect(presenter.available_keys).to eq([other_deploy_key, public_deploy_key])
end
end end
end
context 'with available project keys' do context 'with available keys' do
it 'returns correct deploy keys' do it 'returns correct deploy keys' do
expect(presenter.available_project_keys).to eq([other_deploy_key]) expect(presenter.available_keys).to eq([other_deploy_key, public_deploy_key])
expect(presenter.available_project_keys_size).to eq(1)
end
end end
end
context 'with available public keys' do context 'with available project keys' do
it 'returns correct deploy keys' do it 'returns correct deploy keys' do
expect(presenter.available_public_keys).to eq([public_deploy_key]) expect(presenter.available_project_keys).to eq([other_deploy_key])
expect(presenter.available_public_keys_size).to eq(1) expect(presenter.available_project_keys_size).to eq(1)
end
end end
end end
it_behaves_like 'correct behavior' context 'with available public keys' do
it 'returns correct deploy keys' do
context 'when optimize_deploy_keys_presenter feature flag is disabled' do expect(presenter.available_public_keys).to eq([public_deploy_key])
before do expect(presenter.available_public_keys_size).to eq(1)
stub_feature_flags(optimize_deploy_keys_presenter: false)
end end
it_behaves_like 'correct behavior'
end end
end end
......
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