Class: Namespaces::ProjectsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/namespaces/projects_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(namespace: nil, current_user: nil, params: {}) ⇒ ProjectsFinder

Returns a new instance of ProjectsFinder.



20
21
22
23
24
# File 'app/finders/namespaces/projects_finder.rb', line 20

def initialize(namespace: nil, current_user: nil, params: {})
  @namespace = namespace
  @current_user = current_user
  @params = params
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/finders/namespaces/projects_finder.rb', line 26

def execute
  return Project.none if namespace.nil?

  collection = if params[:include_subgroups].present?
                 namespace.all_projects.with_route
               else
                 namespace.projects.with_route
               end

  collection = collection.not_aimed_for_deletion if params[:not_aimed_for_deletion].present?

  collection = filter_projects(collection)

  sort(collection)
end