Commit d0a94468 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '322059-remove-api_v3_repos_events_optimization-flag' into 'master'

Enable optimal API v3/repos/{full-path}/events [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!55442
parents 3716dfa0 c34aa63e
---
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
user_project = find_project_with_access(params)
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)
end
present paginate(merge_requests), with: ::API::Github::Entities::PullRequestEvent
end
......
......@@ -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)
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
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) }
......
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