summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-05-26 15:39:38 +0200
committerToon Claes <toon@gitlab.com>2017-05-30 22:45:59 +0200
commit5654ac877df5b6007606e0e1827d965bdf8e552b (patch)
tree6caad9c2c589617201b86d88c528b6105c15215a /app/finders
parent0f0b9a8466747f69e210fc27778f96ab8ef628bc (diff)
downloadgitlab-ce-5654ac877df5b6007606e0e1827d965bdf8e552b.tar.gz
Make it possible to combine :trending with other params
Now it is possible to combine the :non_public parameter. This might be useful when a user wants to know the trending projects they are member of.
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/projects_finder.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 1d365e7cd7d..866d95ea1d7 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -32,6 +32,7 @@ class ProjectsFinder < UnionFinder
item = by_ids(item)
item = by_personal(item)
item = by_starred(item)
+ item = by_trending(item)
item = by_visibilty_level(item)
item = by_tags(item)
item = by_search(item)
@@ -46,12 +47,8 @@ class ProjectsFinder < UnionFinder
def init_collection
projects = []
- if params[:trending].present?
- projects << Project.trending
- else
- projects << current_user.authorized_projects if current_user
- projects << Project.unscoped.public_to_user(current_user) unless params[:non_public].present?
- end
+ projects << current_user.authorized_projects if current_user
+ projects << Project.unscoped.public_to_user(current_user) unless params[:non_public].present?
projects
end
@@ -72,6 +69,10 @@ class ProjectsFinder < UnionFinder
(params[:starred].present? && current_user) ? items.starred_by(current_user) : items
end
+ def by_trending(items)
+ params[:trending].present? ? items.trending : items
+ end
+
def by_visibilty_level(items)
params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items
end