Class: Admin::ProjectsFinder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params:, current_user:) ⇒ ProjectsFinder

Returns a new instance of ProjectsFinder.


6
7
8
9
# File 'app/finders/admin/projects_finder.rb', line 6

def initialize(params:, current_user:)
  @params = params
  @current_user = current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


4
5
6
# File 'app/finders/admin/projects_finder.rb', line 4

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params


4
5
6
# File 'app/finders/admin/projects_finder.rb', line 4

def params
  @params
end

Instance Method Details

#executeObject

rubocop: disable CodeReuse/ActiveRecord


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/finders/admin/projects_finder.rb', line 12

def execute
  items = Project.without_deleted.with_statistics.with_route
  items = by_namespace_id(items)
  items = by_visibility_level(items)
  items = by_with_push(items)
  items = by_abandoned(items)
  items = by_last_repository_check_failed(items)
  items = by_archived(items)
  items = by_personal(items)
  items = by_name(items)
  items = items.includes(namespace: [:owner, :route])
  sort(items).page(params[:page])
end