Class: UsersFinder

Inherits:
Object
  • Object
show all
Includes:
CreatedAtFilter, CustomAttributesFilter
Defined in:
app/finders/users_finder.rb

Overview

UsersFinder

Used to filter users by set of params

Arguments:

current_user - which user use
params:
  username: string
  extern_uid: string
  provider: string
  search: string
  active: boolean
  blocked: boolean
  external: boolean
  non_external: boolean
  without_projects: boolean
  sort: string
  id: integer
  non_internal: boolean

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CustomAttributesFilter

#by_custom_attributes

Methods included from CreatedAtFilter

#by_created_at

Constructor Details

#initialize(current_user, params = {}) ⇒ UsersFinder

Returns a new instance of UsersFinder.


29
30
31
32
# File 'app/finders/users_finder.rb', line 29

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

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.


27
28
29
# File 'app/finders/users_finder.rb', line 27

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params.


27
28
29
# File 'app/finders/users_finder.rb', line 27

def params
  @params
end

Instance Method Details

#executeObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/finders/users_finder.rb', line 34

def execute
  users = base_scope
  users = by_username(users)
  users = by_id(users)
  users = by_admins(users)
  users = by_search(users)
  users = by_blocked(users)
  users = by_active(users)
  users = by_external_identity(users)
  users = by_external(users)
  users = by_non_external(users)
  users = by_2fa(users)
  users = by_created_at(users)
  users = by_without_projects(users)
  users = by_custom_attributes(users)
  users = by_non_internal(users)
  users = by_without_project_bots(users)

  order(users)
end