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
53076f2e
Commit
53076f2e
authored
Aug 06, 2021
by
Alex Pooley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group finder with linear queries
parent
572c72dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
+39
-5
app/finders/groups_finder.rb
app/finders/groups_finder.rb
+17
-4
config/feature_flags/development/use_traversal_ids_groups_finder.yml
...ure_flags/development/use_traversal_ids_groups_finder.yml
+8
-0
spec/finders/groups_finder_spec.rb
spec/finders/groups_finder_spec.rb
+14
-1
No files found.
app/finders/groups_finder.rb
View file @
53076f2e
...
@@ -52,7 +52,16 @@ class GroupsFinder < UnionFinder
...
@@ -52,7 +52,16 @@ class GroupsFinder < UnionFinder
return
[
Group
.
all
]
if
current_user
&
.
can_read_all_resources?
&&
all_available?
return
[
Group
.
all
]
if
current_user
&
.
can_read_all_resources?
&&
all_available?
groups
=
[]
groups
=
[]
groups
<<
Gitlab
::
ObjectHierarchy
.
new
(
groups_for_ancestors
,
groups_for_descendants
).
all_objects
if
current_user
if
current_user
if
Feature
.
enabled?
(
:use_traversal_ids_groups_finder
,
default_enabled: :yaml
)
groups
<<
current_user
.
authorized_groups
.
self_and_ancestors
groups
<<
current_user
.
groups
.
self_and_descendants
else
groups
<<
Gitlab
::
ObjectHierarchy
.
new
(
groups_for_ancestors
,
groups_for_descendants
).
all_objects
end
end
groups
<<
Group
.
unscoped
.
public_to_user
(
current_user
)
if
include_public_groups?
groups
<<
Group
.
unscoped
.
public_to_user
(
current_user
)
if
include_public_groups?
groups
<<
Group
.
none
if
groups
.
empty?
groups
<<
Group
.
none
if
groups
.
empty?
groups
groups
...
@@ -72,9 +81,13 @@ class GroupsFinder < UnionFinder
...
@@ -72,9 +81,13 @@ class GroupsFinder < UnionFinder
.
groups
.
groups
.
where
(
'members.access_level >= ?'
,
params
[
:min_access_level
])
.
where
(
'members.access_level >= ?'
,
params
[
:min_access_level
])
Gitlab
::
ObjectHierarchy
if
Feature
.
enabled?
(
:use_traversal_ids_groups_finder
,
default_enabled: :yaml
)
.
new
(
groups
)
groups
.
self_and_descendants
.
base_and_descendants
else
Gitlab
::
ObjectHierarchy
.
new
(
groups
)
.
base_and_descendants
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
config/feature_flags/development/use_traversal_ids_groups_finder.yml
0 → 100644
View file @
53076f2e
---
name
:
use_traversal_ids_groups_finder
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67650
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/345666
milestone
:
'
14.6'
type
:
development
group
:
group::access
default_enabled
:
false
spec/finders/groups_finder_spec.rb
View file @
53076f2e
...
@@ -5,7 +5,7 @@ require 'spec_helper'
...
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec
.
describe
GroupsFinder
do
RSpec
.
describe
GroupsFinder
do
include
AdminModeHelper
include
AdminModeHelper
describe
'#execute'
do
shared_examples
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
'root level groups'
do
describe
'root level groups'
do
...
@@ -20,6 +20,7 @@ RSpec.describe GroupsFinder do
...
@@ -20,6 +20,7 @@ RSpec.describe GroupsFinder do
user_private_group)
user_private_group)
:regular
|
{
all_available:
false
}
|
%i(user_public_group user_internal_group user_private_group)
:regular
|
{
all_available:
false
}
|
%i(user_public_group user_internal_group user_private_group)
:regular
|
{}
|
%i(public_group internal_group user_public_group user_internal_group user_private_group)
:regular
|
{}
|
%i(public_group internal_group user_public_group user_internal_group user_private_group)
:regular
|
{
min_access_level:
Gitlab
::
Access
::
DEVELOPER
}
|
%i(user_public_group user_internal_group user_private_group)
:external
|
{
all_available:
true
}
|
%i(public_group user_public_group user_internal_group user_private_group)
:external
|
{
all_available:
true
}
|
%i(public_group user_public_group user_internal_group user_private_group)
:external
|
{
all_available:
false
}
|
%i(user_public_group user_internal_group user_private_group)
:external
|
{
all_available:
false
}
|
%i(user_public_group user_internal_group user_private_group)
...
@@ -261,4 +262,16 @@ RSpec.describe GroupsFinder do
...
@@ -261,4 +262,16 @@ RSpec.describe GroupsFinder do
end
end
end
end
end
end
describe
'#execute'
do
include_examples
'#execute'
context
'when use_traversal_ids_groups_finder feature flags is disabled'
do
before
do
stub_feature_flags
(
use_traversal_ids_groups_finder:
false
)
end
include_examples
'#execute'
end
end
end
end
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