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
faf04375
Commit
faf04375
authored
Jul 29, 2019
by
Jason Goodman
Committed by
Bob Van Landuyt
Jul 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor feature flag scopes for_unleash_client
Join feature flags rather than use delegate
parent
29bd2927
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
ee/app/models/operations/feature_flag_scope.rb
ee/app/models/operations/feature_flag_scope.rb
+5
-1
ee/changelogs/unreleased/refactor-for-unleash-client.yml
ee/changelogs/unreleased/refactor-for-unleash-client.yml
+5
-0
ee/spec/requests/api/unleash_spec.rb
ee/spec/requests/api/unleash_spec.rb
+7
-5
No files found.
ee/app/models/operations/feature_flag_scope.rb
View file @
faf04375
...
...
@@ -25,10 +25,14 @@ module Operations
scope
:enabled
,
->
{
where
(
active:
true
)
}
scope
:disabled
,
->
{
where
(
active:
false
)
}
delegate
:name
,
:description
,
to: :feature_flag
def
self
.
with_name_and_description
joins
(
:feature_flag
)
.
select
(
FeatureFlag
.
arel_table
[
:name
],
FeatureFlag
.
arel_table
[
:description
])
end
def
self
.
for_unleash_client
(
project
,
environment
)
select
(
'DISTINCT ON (operations_feature_flag_scopes.feature_flag_id) operations_feature_flag_scopes.*'
)
.
with_name_and_description
.
where
(
feature_flag_id:
project
.
operations_feature_flags
.
select
(
:id
))
.
order
(
:feature_flag_id
)
.
on_environment
(
environment
)
...
...
ee/changelogs/unreleased/refactor-for-unleash-client.yml
0 → 100644
View file @
faf04375
---
title
:
Refactor feature flag scopes for_unleash_client
merge_request
:
14768
author
:
type
:
performance
ee/spec/requests/api/unleash_spec.rb
View file @
faf04375
...
...
@@ -69,9 +69,9 @@ describe API::Unleash do
end
shared_examples_for
'support multiple environments'
do
let
(
:client
)
{
create
(
:operations_feature_flags_client
,
project:
project
)
}
let
(
:base_headers
)
{
{
"UNLEASH-INSTANCEID"
=>
client
.
token
}
}
let
(
:headers
)
{
base_headers
.
merge
({
"UNLEASH-APPNAME"
=>
"test"
})
}
let
!
(
:client
)
{
create
(
:operations_feature_flags_client
,
project:
project
)
}
let
!
(
:base_headers
)
{
{
"UNLEASH-INSTANCEID"
=>
client
.
token
}
}
let
!
(
:headers
)
{
base_headers
.
merge
({
"UNLEASH-APPNAME"
=>
"test"
})
}
let!
(
:feature_flag_1
)
do
create
(
:operations_feature_flag
,
name:
"feature_flag_1"
,
project:
project
,
active:
true
)
...
...
@@ -87,9 +87,11 @@ describe API::Unleash do
end
it
'does not have N+1 problem'
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
get
api
(
features_url
),
headers:
headers
}.
count
expect
(
recorded
.
count
).
to
be_within
(
8
).
of
(
10
)
create
(
:operations_feature_flag
,
name:
"feature_flag_3"
,
project:
project
,
active:
true
)
expect
{
get
api
(
features_url
),
headers:
headers
}.
not_to
exceed_query_limit
(
control_count
)
end
context
'when app name is staging'
do
...
...
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