Commit fb94cc6e authored by David Fernandez's avatar David Fernandez Committed by Vitali Tatarintev

Remove the packages_npm_abbreviated_metadata feature flag

parent ab8d113a
...@@ -12,10 +12,9 @@ module Packages ...@@ -12,10 +12,9 @@ module Packages
attr_reader :name, :packages attr_reader :name, :packages
def initialize(name, packages, include_metadata: false) def initialize(name, packages)
@name = name @name = name
@packages = packages @packages = packages
@include_metadata = include_metadata
end end
def versions def versions
...@@ -24,10 +23,7 @@ module Packages ...@@ -24,10 +23,7 @@ module Packages
packages.each_batch do |relation| packages.each_batch do |relation|
batched_packages = relation.including_dependency_links batched_packages = relation.including_dependency_links
.preload_files .preload_files
.preload_npm_metadatum
if @include_metadata
batched_packages = batched_packages.preload_npm_metadatum
end
batched_packages.each do |package| batched_packages.each do |package|
package_file = package.package_files.last package_file = package.package_files.last
...@@ -92,8 +88,6 @@ module Packages ...@@ -92,8 +88,6 @@ module Packages
end end
def abbreviated_package_json(package) def abbreviated_package_json(package)
return {} unless @include_metadata
json = package.npm_metadatum&.package_json || {} json = package.npm_metadatum&.package_json || {}
json.slice(*PACKAGE_JSON_ALLOWED_FIELDS) json.slice(*PACKAGE_JSON_ALLOWED_FIELDS)
end end
......
...@@ -23,9 +23,7 @@ module Packages ...@@ -23,9 +23,7 @@ module Packages
::Packages::CreateDependencyService.new(package, package_dependencies).execute ::Packages::CreateDependencyService.new(package, package_dependencies).execute
::Packages::Npm::CreateTagService.new(package, dist_tag).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)
package.create_npm_metadatum!(package_json: package_json)
end
package package
end 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 ...@@ -121,9 +121,7 @@ module API
not_found!('Packages') if packages.empty? 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),
present ::Packages::Npm::PackagePresenter.new(package_name, packages, include_metadata: include_metadata),
with: ::API::Entities::NpmPackage with: ::API::Entities::NpmPackage
end end
end end
......
...@@ -32,22 +32,15 @@ RSpec.describe ::Packages::Npm::PackagePresenter do ...@@ -32,22 +32,15 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
} }
end end
let(:presenter) { described_class.new(package_name, packages, include_metadata: include_metadata) } let(:presenter) { described_class.new(package_name, packages) }
subject { presenter.versions } subject { presenter.versions }
where(:has_dependencies, :has_metadatum, :include_metadata) do where(:has_dependencies, :has_metadatum) do
true | true | true true | true
false | true | true false | true
true | false | true true | false
false | false | true false | false
# 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
end end
with_them do with_them do
...@@ -80,7 +73,7 @@ RSpec.describe ::Packages::Npm::PackagePresenter do ...@@ -80,7 +73,7 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
context 'metadatum' do context 'metadatum' do
::Packages::Npm::PackagePresenter::PACKAGE_JSON_ALLOWED_FIELDS.each do |metadata_field| ::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 } it { expect(subject.dig(package1.version, metadata_field)).not_to be nil }
else else
it { expect(subject.dig(package1.version, metadata_field)).to be nil } it { expect(subject.dig(package1.version, metadata_field)).to be nil }
......
...@@ -89,17 +89,6 @@ RSpec.describe Packages::Npm::CreatePackageService do ...@@ -89,17 +89,6 @@ RSpec.describe Packages::Npm::CreatePackageService do
end end
end 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 end
describe '#execute' do describe '#execute' do
......
...@@ -41,19 +41,6 @@ RSpec.shared_examples 'handling get metadata requests' do |scope: :project| ...@@ -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 # 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) expect { get(url, headers: headers) }.not_to exceed_query_limit(control).with_threshold(4)
end 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 end
shared_examples 'reject metadata request' do |status:| 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