Commit 81f06b6a authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '344827-cleanup-feature-flag' into 'master'

Remove the packages_npm_abbreviated_metadata feature flag

See merge request gitlab-org/gitlab!75239
parents 52c1194a fb94cc6e
......@@ -12,10 +12,9 @@ module Packages
attr_reader :name, :packages
def initialize(name, packages, include_metadata: false)
def initialize(name, packages)
@name = name
@packages = packages
@include_metadata = include_metadata
end
def versions
......@@ -24,10 +23,7 @@ module Packages
packages.each_batch do |relation|
batched_packages = relation.including_dependency_links
.preload_files
if @include_metadata
batched_packages = batched_packages.preload_npm_metadatum
end
.preload_npm_metadatum
batched_packages.each do |package|
package_file = package.package_files.last
......@@ -92,8 +88,6 @@ module Packages
end
def abbreviated_package_json(package)
return {} unless @include_metadata
json = package.npm_metadatum&.package_json || {}
json.slice(*PACKAGE_JSON_ALLOWED_FIELDS)
end
......
......@@ -23,9 +23,7 @@ module Packages
::Packages::CreateDependencyService.new(package, package_dependencies).execute
::Packages::Npm::CreateTagService.new(package, dist_tag).execute
if Feature.enabled?(:packages_npm_abbreviated_metadata, project, default_enabled: :yaml)
package.create_npm_metadatum!(package_json: package_json)
end
package
end
......
---
name: packages_npm_abbreviated_metadata
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73639
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/344827
milestone: '14.5'
type: development
group: group::package
default_enabled: true
......@@ -121,9 +121,7 @@ module API
not_found!('Packages') if packages.empty?
include_metadata = Feature.enabled?(:packages_npm_abbreviated_metadata, project, default_enabled: :yaml)
present ::Packages::Npm::PackagePresenter.new(package_name, packages, include_metadata: include_metadata),
present ::Packages::Npm::PackagePresenter.new(package_name, packages),
with: ::API::Entities::NpmPackage
end
end
......
......@@ -32,22 +32,15 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
}
end
let(:presenter) { described_class.new(package_name, packages, include_metadata: include_metadata) }
let(:presenter) { described_class.new(package_name, packages) }
subject { presenter.versions }
where(:has_dependencies, :has_metadatum, :include_metadata) do
true | true | true
false | true | true
true | false | true
false | false | true
# TODO : to remove along with packages_npm_abbreviated_metadata
# See https://gitlab.com/gitlab-org/gitlab/-/issues/344827
true | true | false
false | true | false
true | false | false
false | false | false
where(:has_dependencies, :has_metadatum) do
true | true
false | true
true | false
false | false
end
with_them do
......@@ -80,7 +73,7 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
context 'metadatum' do
::Packages::Npm::PackagePresenter::PACKAGE_JSON_ALLOWED_FIELDS.each do |metadata_field|
if params[:has_metadatum] && params[:include_metadata]
if params[:has_metadatum]
it { expect(subject.dig(package1.version, metadata_field)).not_to be nil }
else
it { expect(subject.dig(package1.version, metadata_field)).to be nil }
......
......@@ -89,17 +89,6 @@ RSpec.describe Packages::Npm::CreatePackageService do
end
end
end
context 'with packages_npm_abbreviated_metadata disabled' do
before do
stub_feature_flags(packages_npm_abbreviated_metadata: false)
end
it 'creates a package without metadatum' do
expect { subject }
.not_to change { Packages::Npm::Metadatum.count }
end
end
end
describe '#execute' do
......
......@@ -41,19 +41,6 @@ RSpec.shared_examples 'handling get metadata requests' do |scope: :project|
# query count can slightly change between the examples so we're using a custom threshold
expect { get(url, headers: headers) }.not_to exceed_query_limit(control).with_threshold(4)
end
context 'with packages_npm_abbreviated_metadata disabled' do
before do
stub_feature_flags(packages_npm_abbreviated_metadata: false)
end
it 'calls the presenter without including metadata' do
expect(::Packages::Npm::PackagePresenter)
.to receive(:new).with(anything, anything, include_metadata: false).and_call_original
subject
end
end
end
shared_examples 'reject metadata request' do |status:|
......
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