Commit c34aa63e authored by Luke Duncalfe's avatar Luke Duncalfe Committed by Bob Van Landuyt

Enable optimimal API v3/repos/{full-path}/events

Removing the feature flag added in
44777e66

https://gitlab.com/gitlab-org/gitlab/-/issues/321839
https://gitlab.com/gitlab-org/gitlab/-/issues/322059
parent a14eb451
---
title: Fix N+1 queries in api/v3/repos/:namespace/:project/events endpoint
merge_request: 55442
author:
type: performance
---
name: api_v3_repos_events_optimization
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/54618
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/322059
milestone: '13.10'
type: development
group: group::ecosystem
default_enabled: false
...@@ -199,10 +199,7 @@ module API ...@@ -199,10 +199,7 @@ module API
user_project = find_project_with_access(params) user_project = find_project_with_access(params)
merge_requests = authorized_merge_requests_for_project(user_project) merge_requests = authorized_merge_requests_for_project(user_project)
if Feature.enabled?(:api_v3_repos_events_optimization, user_project)
merge_requests = merge_requests.preload(:author, :assignees, :metrics, source_project: :namespace, target_project: :namespace) merge_requests = merge_requests.preload(:author, :assignees, :metrics, source_project: :namespace, target_project: :namespace)
end
present paginate(merge_requests), with: ::API::Github::Entities::PullRequestEvent present paginate(merge_requests), with: ::API::Github::Entities::PullRequestEvent
end end
......
...@@ -187,23 +187,6 @@ RSpec.describe API::V3::Github do ...@@ -187,23 +187,6 @@ RSpec.describe API::V3::Github do
expect { jira_get v3_api(events_path, user) }.not_to exceed_all_query_limit(control_count) expect { jira_get v3_api(events_path, user) }.not_to exceed_all_query_limit(control_count)
end end
context 'with `api_v3_repos_events_optimization` feature flag disabled' do
before do
stub_feature_flags(api_v3_repos_events_optimization: false)
end
it 'falls back to less optimal query performance' do
create(:merge_request, source_project: project)
source_project = fork_project(project, nil, repository: true)
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) { jira_get v3_api(events_path, user) }.count
create_list(:merge_request, 2, :unique_branches, source_project: source_project, target_project: project)
expect { jira_get v3_api(events_path, user) }.to exceed_all_query_limit(control_count)
end
end
context 'if there are more merge requests' do context 'if there are more merge requests' do
let!(:merge_request) { create(:merge_request, id: 10000, source_project: project, target_project: project, author: user) } let!(:merge_request) { create(:merge_request, id: 10000, source_project: project, target_project: project, author: user) }
let!(:merge_request2) { create(:merge_request, id: 10001, source_project: project, source_branch: generate(:branch), target_project: project, author: user) } let!(:merge_request2) { create(:merge_request, id: 10001, source_project: project, source_branch: generate(:branch), target_project: project, author: user) }
......
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