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
4dd097fc
Commit
4dd097fc
authored
Mar 28, 2022
by
Jaspreet Singh
Committed by
Andy Soiron
Mar 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup api_kaminari_count_with_limit feature flag
Changelog: removed
parent
4224b844
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
67 deletions
+40
-67
config/feature_flags/ops/api_kaminari_count_with_limit.yml
config/feature_flags/ops/api_kaminari_count_with_limit.yml
+0
-8
doc/api/features.md
doc/api/features.md
+15
-13
lib/gitlab/pagination/offset_pagination.rb
lib/gitlab/pagination/offset_pagination.rb
+0
-1
spec/lib/gitlab/pagination/offset_pagination_spec.rb
spec/lib/gitlab/pagination/offset_pagination_spec.rb
+25
-45
No files found.
config/feature_flags/ops/api_kaminari_count_with_limit.yml
deleted
100644 → 0
View file @
4224b844
---
name
:
api_kaminari_count_with_limit
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/23931
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/353077
milestone
:
'
11.8'
type
:
ops
group
:
group::integrations
default_enabled
:
true
doc/api/features.md
View file @
4dd097fc
...
...
@@ -89,22 +89,24 @@ Example response:
```
json
[
{
"name"
:
"api_kaminari_count_with_limit"
,
"introduced_by_url"
:
"https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/23931"
,
"rollout_issue_url"
:
null
,
"milestone"
:
"11.8"
,
"type"
:
"ops"
,
"group"
:
"group::ecosystem"
,
"name"
:
"geo_pages_deployment_replication"
,
"introduced_by_url"
:
"https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68662"
,
"rollout_issue_url"
:
"https://gitlab.com/gitlab-org/gitlab/-/issues/337676"
,
"milestone"
:
"14.3"
,
"log_state_changes"
:
null
,
"type"
:
"development"
,
"group"
:
"group::geo"
,
"default_enabled"
:
true
},
{
"name"
:
"marginalia"
,
"introduced_by_url"
:
null
,
"rollout_issue_url"
:
null
,
"milestone"
:
null
,
"type"
:
"ops"
,
"group"
:
null
,
"default_enabled"
:
false
"name"
:
"analytics_devops_adoption_codeowners"
,
"introduced_by_url"
:
"https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59874"
,
"rollout_issue_url"
:
"https://gitlab.com/gitlab-org/gitlab/-/issues/328542"
,
"milestone"
:
"13.12"
,
"log_state_changes"
:
null
,
"type"
:
"development"
,
"group"
:
"group::optimize"
,
"default_enabled"
:
true
}
]
```
...
...
lib/gitlab/pagination/offset_pagination.rb
View file @
4dd097fc
...
...
@@ -27,7 +27,6 @@ module Gitlab
end
return
pagination_data
unless
pagination_data
.
is_a?
(
ActiveRecord
::
Relation
)
return
pagination_data
unless
Feature
.
enabled?
(
:api_kaminari_count_with_limit
,
type: :ops
,
default_enabled: :yaml
)
limited_total_count
=
pagination_data
.
total_count_with_limit
if
limited_total_count
>
Kaminari
::
ActiveRecordRelationMethods
::
MAX_COUNT_LIMIT
...
...
spec/lib/gitlab/pagination/offset_pagination_spec.rb
View file @
4dd097fc
...
...
@@ -66,70 +66,50 @@ RSpec.describe Gitlab::Pagination::OffsetPagination do
let
(
:query
)
{
base_query
.
merge
(
page:
1
,
per_page:
2
)
}
context
'when the api_kaminari_count_with_limit feature flag is unset'
do
it_behaves_like
'paginated response'
it_behaves_like
'response with pagination headers'
end
context
'when the api_kaminari_count_with_limit feature flag is disabled'
do
context
'when resources count is less than MAX_COUNT_LIMIT'
do
before
do
stub_
feature_flags
(
api_kaminari_count_with_limit:
false
)
stub_
const
(
"::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT"
,
4
)
end
it_behaves_like
'paginated response'
it_behaves_like
'response with pagination headers'
end
context
'when
the api_kaminari_count_with_limit feature flag is enabled
'
do
context
'when
resources count is more than MAX_COUNT_LIMIT
'
do
before
do
stub_feature_flags
(
api_kaminari_count_with_limit:
true
)
end
context
'when resources count is less than MAX_COUNT_LIMIT'
do
before
do
stub_const
(
"::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT"
,
4
)
end
it_behaves_like
'paginated response'
it_behaves_like
'response with pagination headers'
stub_const
(
"::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT"
,
2
)
end
context
'when resources count is more than MAX_COUNT_LIMIT'
do
before
do
stub_const
(
"::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT"
,
2
)
end
it_behaves_like
'paginated response'
it
'does not return the X-Total and X-Total-Pages headers'
do
expect_no_header
(
'X-Total'
)
expect_no_header
(
'X-Total-Pages'
)
expect_header
(
'X-Per-Page'
,
'2'
)
expect_header
(
'X-Page'
,
'1'
)
expect_header
(
'X-Next-Page'
,
'2'
)
expect_header
(
'X-Prev-Page'
,
''
)
expect_header
(
'Link'
,
anything
)
do
|
_key
,
val
|
expect
(
val
).
to
include
(
%Q(<
#{
incoming_api_projects_url
}
?
#{
query
.
merge
(
page:
1
).
to_query
}
>; rel="first")
)
expect
(
val
).
to
include
(
%Q(<
#{
incoming_api_projects_url
}
?
#{
query
.
merge
(
page:
2
).
to_query
}
>; rel="next")
)
expect
(
val
).
not_to
include
(
'rel="last"'
)
expect
(
val
).
not_to
include
(
'rel="prev"'
)
end
subject
.
paginate
(
resource
)
end
end
it_behaves_like
'paginated response'
it
'does not return the
total headers when excluding them
'
do
it
'does not return the
X-Total and X-Total-Pages headers
'
do
expect_no_header
(
'X-Total'
)
expect_no_header
(
'X-Total-Pages'
)
expect_header
(
'X-Per-Page'
,
'2'
)
expect_header
(
'X-Page'
,
'1'
)
expect_header
(
'X-Next-Page'
,
'2'
)
expect_header
(
'X-Prev-Page'
,
''
)
paginator
.
paginate
(
resource
,
exclude_total_headers:
true
)
expect_header
(
'Link'
,
anything
)
do
|
_key
,
val
|
expect
(
val
).
to
include
(
%Q(<
#{
incoming_api_projects_url
}
?
#{
query
.
merge
(
page:
1
).
to_query
}
>; rel="first")
)
expect
(
val
).
to
include
(
%Q(<
#{
incoming_api_projects_url
}
?
#{
query
.
merge
(
page:
2
).
to_query
}
>; rel="next")
)
expect
(
val
).
not_to
include
(
'rel="last"'
)
expect
(
val
).
not_to
include
(
'rel="prev"'
)
end
subject
.
paginate
(
resource
)
end
end
it
'does not return the total headers when excluding them'
do
expect_no_header
(
'X-Total'
)
expect_no_header
(
'X-Total-Pages'
)
expect_header
(
'X-Per-Page'
,
'2'
)
expect_header
(
'X-Page'
,
'1'
)
paginator
.
paginate
(
resource
,
exclude_total_headers:
true
)
end
context
'when resource already paginated'
do
let
(
:resource
)
{
Project
.
all
.
page
(
1
).
per
(
1
)
}
...
...
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