Commit 10f7d325 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'cleanup-api_caching_releases-feature-flag' into 'master'

Cleanup api_caching_releases feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61223
parents 1622d29a d0318ed6
---
title: Improve the performance of Release LIST v4 API endpoint by short-interval caching
merge_request: 61223
author:
type: performance
---
name: api_caching_releases
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60194
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329861
milestone: '13.12'
type: development
group: group::release
default_enabled: false
......@@ -33,21 +33,17 @@ module API
get ':id/releases' do
releases = ::ReleasesFinder.new(user_project, current_user, declared_params.slice(:order_by, :sort)).execute
if Feature.enabled?(:api_caching_releases, user_project, default_enabled: :yaml)
# We cache the serialized payload per user in order to avoid repeated renderings.
# Since the cached result could contain sensitive information,
# it will expire in a short interval.
present_cached paginate(releases),
with: Entities::Release,
# `current_user` could be absent if the releases are publicly accesible.
# We should not use `cache_key` for the user because the version/updated_at
# context is unnecessary here.
cache_context: -> (_) { "user:{#{current_user&.id}}" },
expires_in: 5.minutes,
current_user: current_user
else
present paginate(releases), with: Entities::Release, current_user: current_user
end
# We cache the serialized payload per user in order to avoid repeated renderings.
# Since the cached result could contain sensitive information,
# it will expire in a short interval.
present_cached paginate(releases),
with: Entities::Release,
# `current_user` could be absent if the releases are publicly accesible.
# We should not use `cache_key` for the user because the version/updated_at
# context is unnecessary here.
cache_context: -> (_) { "user:{#{current_user&.id}}" },
expires_in: 5.minutes,
current_user: current_user
end
desc 'Get a single project release' do
......
......@@ -185,22 +185,6 @@ RSpec.describe API::Releases do
3.times { get api("/projects/#{project.id}/releases", maintainer) }
end
context 'when api_caching_releases feature flag is disabled' do
before do
stub_feature_flags(api_caching_releases: false)
end
it 'serializes releases everytime' do
create_list(:release, 2, project: project)
expect(API::Entities::Release)
.to receive(:represent).with(kind_of(ActiveRecord::Relation), any_args)
.exactly(5).times
5.times { get api("/projects/#{project.id}/releases", maintainer) }
end
end
context 'when tag does not exist in git repository' do
let!(:release) { create(:release, project: project, tag: 'v1.1.5') }
......
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