Commit a9ca4575 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'compare-cache-adjustments' into 'master'

Adjustments to compare caching

See merge request gitlab-org/gitlab!65839
parents ba3f488b 9b2f6917
......@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334264
milestone: '14.1'
type: development
group: group::source code
default_enabled: false
default_enabled: true
---
name: api_caching_repository_compare
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64418
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334264
milestone: '14.1'
type: development
group: group::source code
default_enabled: false
......@@ -122,7 +122,7 @@ module API
get ':id/repository/compare' do
ff_enabled = Feature.enabled?(:api_caching_rate_limit_repository_compare, user_project, default_enabled: :yaml)
cache_action_if(ff_enabled, [user_project, :repository_compare, current_user, declared_params], expires_in: 30.seconds) do
cache_action_if(ff_enabled, [user_project, :repository_compare, current_user, declared_params], expires_in: 1.minute) do
if params[:from_project_id].present?
target_project = MergeRequestTargetProjectFinder
.new(current_user: current_user, source_project: user_project, project_feature: :repository)
......@@ -138,11 +138,7 @@ module API
compare = CompareService.new(user_project, params[:to]).execute(target_project, params[:from], straight: params[:straight])
if compare
if Feature.enabled?(:api_caching_repository_compare, user_project, default_enabled: :yaml)
present_cached compare, with: Entities::Compare, expires_in: 1.day, cache_context: nil
else
present compare, with: Entities::Compare
end
present compare, with: Entities::Compare
else
not_found!("Ref")
end
......
......@@ -488,17 +488,6 @@ RSpec.describe API::Repositories do
let(:current_user) { nil }
end
end
context 'api_caching_repository_compare is disabled' do
before do
stub_feature_flags(api_caching_repository_compare: false)
end
it_behaves_like 'repository compare' do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
end
describe 'GET /projects/:id/repository/contributors' do
......
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