Commit daef07bd authored by David Fernandez's avatar David Fernandez

Avoid a duplicated SQL condition in the NPM metadata endpoint

Changelog: performance
parent bd2057d4
---
name: npm_finder_query_avoid_duplicated_conditions
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69572
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/340099
milestone: '14.3'
type: development
group: group::package
default_enabled: false
...@@ -60,7 +60,7 @@ module API ...@@ -60,7 +60,7 @@ module API
finder = ::Packages::Npm::PackageFinder.new( finder = ::Packages::Npm::PackageFinder.new(
package_name, package_name,
namespace: namespace, namespace: namespace,
last_of_each_version: Feature.disabled?(:npm_finder_query_avoid_duplicated_conditions) last_of_each_version: false
) )
finder.last&.project_id finder.last&.project_id
......
...@@ -10,39 +10,27 @@ RSpec.describe API::NpmInstancePackages do ...@@ -10,39 +10,27 @@ RSpec.describe API::NpmInstancePackages do
include_context 'npm api setup' include_context 'npm api setup'
shared_examples 'handling all endpoints' do describe 'GET /api/v4/packages/npm/*package_name' do
describe 'GET /api/v4/packages/npm/*package_name' do it_behaves_like 'handling get metadata requests', scope: :instance do
it_behaves_like 'handling get metadata requests', scope: :instance do let(:url) { api("/packages/npm/#{package_name}") }
let(:url) { api("/packages/npm/#{package_name}") }
end
end
describe 'GET /api/v4/packages/npm/-/package/*package_name/dist-tags' do
it_behaves_like 'handling get dist tags requests', scope: :instance do
let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags") }
end
end end
end
describe 'PUT /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do describe 'GET /api/v4/packages/npm/-/package/*package_name/dist-tags' do
it_behaves_like 'handling create dist tag requests', scope: :instance do it_behaves_like 'handling get dist tags requests', scope: :instance do
let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags/#{tag_name}") } let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags") }
end
end end
end
describe 'DELETE /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do describe 'PUT /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do
it_behaves_like 'handling delete dist tag requests', scope: :instance do it_behaves_like 'handling create dist tag requests', scope: :instance do
let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags/#{tag_name}") } let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags/#{tag_name}") }
end
end end
end end
it_behaves_like 'handling all endpoints' describe 'DELETE /api/v4/packages/npm/-/package/*package_name/dist-tags/:tag' do
it_behaves_like 'handling delete dist tag requests', scope: :instance do
context 'with npm_finder_query_avoid_duplicated_conditions disabled' do let(:url) { api("/packages/npm/-/package/#{package_name}/dist-tags/#{tag_name}") }
before do
stub_feature_flags(npm_finder_query_avoid_duplicated_conditions: false)
end end
it_behaves_like 'handling all endpoints'
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