Commit 8d12d7a8 authored by Shinya Maeda's avatar Shinya Maeda

Remove optimize_deploy_keys_presenter feature flag

This commit removes the optimize_deploy_keys_presenter feature flag
as it's deemed stable.
parent 922d9e58
......@@ -42,18 +42,9 @@ module Projects
# It excludes:
# - The deploy keys enabled in the project
def available_project_keys
if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml)
strong_memoize(:available_project_keys) do
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
# It includes:
......@@ -61,23 +52,9 @@ module Projects
# It excludes:
# - The deploy keys enabled in the project.
def available_public_keys
if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml)
strong_memoize(:available_public_keys) do
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
def as_json
......@@ -110,17 +87,10 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def user_readable_project_ids
project_ids = if Feature.enabled?(:optimize_deploy_keys_presenter, project, default_enabled: :yaml)
(available_project_keys + available_public_keys)
.flat_map { |deploy_key| deploy_key.deploy_keys_projects.map(&:project_id) }
.compact
.uniq
else
(available_keys + available_project_keys + available_public_keys)
project_ids = (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)
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,7 +27,6 @@ RSpec.describe Projects::Settings::DeployKeysPresenter do
let_it_be(:unrelated_project) { create(:project, :private) }
let_it_be(:unrelated_deploy_key) { create(:deploy_key, projects: [unrelated_project]) }
shared_examples_for 'correct behavior' do
context 'with enabled keys' do
it 'returns correct deploy keys' do
expect(presenter.enabled_keys).to eq([deploy_key])
......@@ -56,17 +55,6 @@ RSpec.describe Projects::Settings::DeployKeysPresenter do
end
end
it_behaves_like 'correct behavior'
context 'when optimize_deploy_keys_presenter feature flag is disabled' do
before do
stub_feature_flags(optimize_deploy_keys_presenter: false)
end
it_behaves_like 'correct behavior'
end
end
describe '#enabled_keys' do
let!(:deploy_key) { create(:deploy_key, public: true) }
......
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