Commit 9b2f6917 authored by Robert May's avatar Robert May

Adjustments to compare caching

Removes an ineffective cache and extends the effective one.

Changelog: performance
parent 8ea9b0e2
...@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334264 ...@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334264
milestone: '14.1' milestone: '14.1'
type: development type: development
group: group::source code 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 ...@@ -122,7 +122,7 @@ module API
get ':id/repository/compare' do get ':id/repository/compare' do
ff_enabled = Feature.enabled?(:api_caching_rate_limit_repository_compare, user_project, default_enabled: :yaml) 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? if params[:from_project_id].present?
target_project = MergeRequestTargetProjectFinder target_project = MergeRequestTargetProjectFinder
.new(current_user: current_user, source_project: user_project, project_feature: :repository) .new(current_user: current_user, source_project: user_project, project_feature: :repository)
...@@ -138,11 +138,7 @@ module API ...@@ -138,11 +138,7 @@ module API
compare = CompareService.new(user_project, params[:to]).execute(target_project, params[:from], straight: params[:straight]) compare = CompareService.new(user_project, params[:to]).execute(target_project, params[:from], straight: params[:straight])
if compare if compare
if Feature.enabled?(:api_caching_repository_compare, user_project, default_enabled: :yaml) present compare, with: Entities::Compare
present_cached compare, with: Entities::Compare, expires_in: 1.day, cache_context: nil
else
present compare, with: Entities::Compare
end
else else
not_found!("Ref") not_found!("Ref")
end end
......
...@@ -488,17 +488,6 @@ RSpec.describe API::Repositories do ...@@ -488,17 +488,6 @@ RSpec.describe API::Repositories do
let(:current_user) { nil } let(:current_user) { nil }
end end
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 end
describe 'GET /projects/:id/repository/contributors' do 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