summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/filter_projects.rb
blob: 586f97c5eb47bebf955ebf01693d9be19bacb3a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# == FilterProjects
#
# Controller concern to handle projects filtering
# * by name
# * by archived state
#
module FilterProjects
  extend ActiveSupport::Concern

  def filter_projects(projects)
    projects = projects.search(params[:filter_projects]) if params[:filter_projects].present?
    projects = projects.non_archived if params[:archived].blank?
    projects = projects.personal(current_user) if params[:personal].present? && current_user

    projects
  end
end