From 5654ac877df5b6007606e0e1827d965bdf8e552b Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Fri, 26 May 2017 15:39:38 +0200 Subject: 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. --- app/finders/projects_finder.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/finders') 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 -- cgit v1.2.1