Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d0318ed6
Commit
d0318ed6
authored
May 07, 2021
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup api_caching_releases feature flag
This commit cleans up the api_caching_releases feature flag.
parent
3be50b9f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
39 deletions
+16
-39
changelogs/unreleased/cleanup-api_caching_releases-feature-flag.yml
.../unreleased/cleanup-api_caching_releases-feature-flag.yml
+5
-0
config/feature_flags/development/api_caching_releases.yml
config/feature_flags/development/api_caching_releases.yml
+0
-8
lib/api/releases.rb
lib/api/releases.rb
+11
-15
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+0
-16
No files found.
changelogs/unreleased/cleanup-api_caching_releases-feature-flag.yml
0 → 100644
View file @
d0318ed6
---
title
:
Improve the performance of Release LIST v4 API endpoint by short-interval caching
merge_request
:
61223
author
:
type
:
performance
config/feature_flags/development/api_caching_releases.yml
deleted
100644 → 0
View file @
3be50b9f
---
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
lib/api/releases.rb
View file @
d0318ed6
...
...
@@ -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
...
...
spec/requests/api/releases_spec.rb
View file @
d0318ed6
...
...
@@ -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'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment