Commit 5654ac87 authored by Toon Claes's avatar Toon Claes

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.
parent 0f0b9a84
...@@ -32,6 +32,7 @@ class ProjectsFinder < UnionFinder ...@@ -32,6 +32,7 @@ class ProjectsFinder < UnionFinder
item = by_ids(item) item = by_ids(item)
item = by_personal(item) item = by_personal(item)
item = by_starred(item) item = by_starred(item)
item = by_trending(item)
item = by_visibilty_level(item) item = by_visibilty_level(item)
item = by_tags(item) item = by_tags(item)
item = by_search(item) item = by_search(item)
...@@ -46,12 +47,8 @@ class ProjectsFinder < UnionFinder ...@@ -46,12 +47,8 @@ class ProjectsFinder < UnionFinder
def init_collection def init_collection
projects = [] projects = []
if params[:trending].present? projects << current_user.authorized_projects if current_user
projects << Project.trending projects << Project.unscoped.public_to_user(current_user) unless params[:non_public].present?
else
projects << current_user.authorized_projects if current_user
projects << Project.unscoped.public_to_user(current_user) unless params[:non_public].present?
end
projects projects
end end
...@@ -72,6 +69,10 @@ class ProjectsFinder < UnionFinder ...@@ -72,6 +69,10 @@ class ProjectsFinder < UnionFinder
(params[:starred].present? && current_user) ? items.starred_by(current_user) : items (params[:starred].present? && current_user) ? items.starred_by(current_user) : items
end end
def by_trending(items)
params[:trending].present? ? items.trending : items
end
def by_visibilty_level(items) def by_visibilty_level(items)
params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items
end end
......
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