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
9b8d1fd2
Commit
9b8d1fd2
authored
Jul 15, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove optimized_count_users_by_group_id FF
parent
4828d382
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
52 deletions
+18
-52
app/models/members/group_member.rb
app/models/members/group_member.rb
+1
-8
changelogs/unreleased/remove-ff-in-count-users-by-group.yml
changelogs/unreleased/remove-ff-in-count-users-by-group.yml
+5
-0
spec/models/members/group_member_spec.rb
spec/models/members/group_member_spec.rb
+12
-44
No files found.
app/models/members/group_member.rb
View file @
9b8d1fd2
...
...
@@ -17,14 +17,7 @@ class GroupMember < Member
scope
:of_groups
,
->
(
groups
)
{
where
(
source_id:
groups
.
select
(
:id
))
}
scope
:of_ldap_type
,
->
{
where
(
ldap:
true
)
}
scope
:count_users_by_group_id
,
->
do
if
Feature
.
enabled?
(
:optimized_count_users_by_group_id
)
group
(
:source_id
).
count
else
joins
(
:user
).
group
(
:source_id
).
count
end
end
scope
:count_users_by_group_id
,
->
{
group
(
:source_id
).
count
}
after_create
:update_two_factor_requirement
,
unless: :invite?
after_destroy
:update_two_factor_requirement
,
unless: :invite?
...
...
changelogs/unreleased/remove-ff-in-count-users-by-group.yml
0 → 100644
View file @
9b8d1fd2
---
title
:
Remove optimized_count_users_by_group_id feature flag
merge_request
:
36953
author
:
type
:
performance
spec/models/members/group_member_spec.rb
View file @
9b8d1fd2
...
...
@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec
.
describe
GroupMember
do
context
'scopes'
do
shared_examples
'.count_users_by_group_id'
do
it
'counts users by group ID'
do
user_1
=
create
(
:user
)
user_2
=
create
(
:user
)
...
...
@@ -18,37 +17,6 @@ RSpec.describe GroupMember do
expect
(
described_class
.
count_users_by_group_id
).
to
eq
(
group_1
.
id
=>
2
,
group_2
.
id
=>
1
)
end
end
describe
'.count_users_by_group_id with optimized_count_users_by_group_id feature flag on'
do
before
do
stub_feature_flags
(
optimized_count_users_by_group_id:
true
)
end
it_behaves_like
'.count_users_by_group_id'
it
'does not JOIN users'
do
scope
=
described_class
.
all
expect
(
scope
).
not_to
receive
(
:joins
).
with
(
:user
)
scope
.
count_users_by_group_id
end
end
describe
'.count_users_by_group_id with optimized_count_users_by_group_id feature flag off'
do
before
do
stub_feature_flags
(
optimized_count_users_by_group_id:
false
)
end
it_behaves_like
'.count_users_by_group_id'
it
'does JOIN users'
do
scope
=
described_class
.
all
expect
(
scope
).
to
receive
(
:joins
).
with
(
:user
).
and_call_original
scope
.
count_users_by_group_id
end
end
describe
'.of_ldap_type'
do
it
'returns ldap type users'
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