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
e56556e1
Commit
e56556e1
authored
Jun 07, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use group and project finders instead of direct ActiveRecord relations
parent
3ec37e26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
+13
-12
app/controllers/dashboard/groups_controller.rb
app/controllers/dashboard/groups_controller.rb
+11
-10
app/serializers/group_entity.rb
app/serializers/group_entity.rb
+2
-2
No files found.
app/controllers/dashboard/groups_controller.rb
View file @
e56556e1
class
Dashboard::GroupsController
<
Dashboard
::
ApplicationController
def
index
@groups
=
if
params
[
:parent_id
]
parent
=
Group
.
find
(
params
[
:parent_id
])
@groups
=
if
params
[
:parent_id
]
&&
Group
.
supports_nested_groups?
parent
=
Group
.
find_by
(
id:
params
[
:parent_id
])
if
parent
.
users_with_parents
.
find_by
(
id:
current_user
)
Group
.
where
(
id:
parent
.
children
)
else
Group
.
none
end
else
Group
.
joins
(
:group_members
).
merge
(
current_user
.
group_members
)
end
if
can?
(
current_user
,
:read_group
,
parent
)
GroupsFinder
.
new
(
current_user
,
parent:
parent
).
execute
else
Group
.
none
end
else
current_user
.
groups
end
@groups
=
@groups
.
search
(
params
[
:filter_groups
])
if
params
[
:filter_groups
].
present?
@groups
=
@groups
.
includes
(
:route
)
...
...
app/serializers/group_entity.rb
View file @
e56556e1
...
...
@@ -29,11 +29,11 @@ class GroupEntity < Grape::Entity
end
expose
:has_subgroups
do
|
group
|
group
.
children
.
any?
GroupsFinder
.
new
(
request
.
current_user
,
parent:
group
).
execute
.
any?
end
expose
:number_projects_with_delimiter
do
|
group
|
number_with_delimiter
(
group
.
projects
.
non_archived
.
count
)
number_with_delimiter
(
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
request
.
current_user
).
execute
.
count
)
end
expose
:number_users_with_delimiter
do
|
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