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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
6c2de364
Commit
6c2de364
authored
Oct 02, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up adding ancestors for projects
parent
8a685ca8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
app/finders/group_descendants_finder.rb
app/finders/group_descendants_finder.rb
+13
-4
No files found.
app/finders/group_descendants_finder.rb
View file @
6c2de364
...
@@ -61,14 +61,19 @@ class GroupDescendantsFinder
...
@@ -61,14 +61,19 @@ class GroupDescendantsFinder
paginated_projects
=
paginate_projects_after_groups
(
subgroups_with_counts
)
paginated_projects
=
paginate_projects_after_groups
(
subgroups_with_counts
)
if
params
[
:filter
]
subgroups_with_counts
=
add_project_ancestors_when_searching
(
subgroups_with_counts
,
paginated_projects
)
ancestors_for_project_search
=
ancestors_for_groups
(
Group
.
where
(
id:
paginated_projects
.
select
(
:namespace_id
)))
subgroups_with_counts
=
ancestors_for_project_search
.
with_route
.
select
(
GROUP_SELECTS
)
|
subgroups_with_counts
end
@children
=
subgroups_with_counts
+
paginated_projects
@children
=
subgroups_with_counts
+
paginated_projects
end
end
def
add_project_ancestors_when_searching
(
groups
,
projects
)
return
groups
unless
params
[
:filter
]
project_ancestors
=
ancestors_for_projects
(
projects
)
.
with_route
.
select
(
GROUP_SELECTS
)
groups
|
project_ancestors
end
def
paginate_projects_after_groups
(
loaded_subgroups
)
def
paginate_projects_after_groups
(
loaded_subgroups
)
# We adjust the pagination for projects for the combination with groups:
# We adjust the pagination for projects for the combination with groups:
# - We limit the first page (page 0) where we show projects:
# - We limit the first page (page 0) where we show projects:
...
@@ -138,6 +143,10 @@ class GroupDescendantsFinder
...
@@ -138,6 +143,10 @@ class GroupDescendantsFinder
.
base_and_ancestors
.
where
.
not
(
id:
ancestors_for_parent
)
.
base_and_ancestors
.
where
.
not
(
id:
ancestors_for_parent
)
end
end
def
ancestors_for_projects
(
projects
)
ancestors_for_groups
(
Group
.
where
(
id:
projects
.
select
(
:namespace_id
)))
end
def
subgroups
def
subgroups
return
Group
.
none
unless
Group
.
supports_nested_groups?
return
Group
.
none
unless
Group
.
supports_nested_groups?
return
Group
.
none
unless
can?
(
current_user
,
:read_group
,
parent_group
)
return
Group
.
none
unless
can?
(
current_user
,
:read_group
,
parent_group
)
...
...
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