Commit 77d4546e authored by Yorick Peterse's avatar Yorick Peterse

Reduce queries in GroupProjectsFinder

GroupProjectsFinder#collection_with_user would run the following code:

    if group.users.include?(current_user)

When running this code for multiple groups this would result in one
query being executed for every group.

This commit simple removes the entire "if" statement with the code of
the "else" statement. This ensures both paths use the same code, and
removes the need for explicitly checking if a user is a member of the
group.
parent 954968c6
...@@ -39,15 +39,6 @@ class GroupProjectsFinder < ProjectsFinder ...@@ -39,15 +39,6 @@ class GroupProjectsFinder < ProjectsFinder
end end
def collection_with_user def collection_with_user
if group.users.include?(current_user)
if only_shared?
[shared_projects]
elsif only_owned?
[owned_projects]
else
[shared_projects, owned_projects]
end
else
if only_shared? if only_shared?
[shared_projects.public_or_visible_to_user(current_user)] [shared_projects.public_or_visible_to_user(current_user)]
elsif only_owned? elsif only_owned?
...@@ -59,7 +50,6 @@ class GroupProjectsFinder < ProjectsFinder ...@@ -59,7 +50,6 @@ class GroupProjectsFinder < ProjectsFinder
] ]
end end
end end
end
def collection_without_user def collection_without_user
if only_shared? if only_shared?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment