Class: Crm::ContactsFinder

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Allowable, Gitlab::Utils::StrongMemoize
Defined in:
app/finders/crm/contacts_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Constructor Details

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

Returns a new instance of ContactsFinder.



24
25
26
27
# File 'app/finders/crm/contacts_finder.rb', line 24

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

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



17
18
19
# File 'app/finders/crm/contacts_finder.rb', line 17

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.



17
18
19
# File 'app/finders/crm/contacts_finder.rb', line 17

def params
  @params
end

Class Method Details

.counts_by_state(current_user, params = {}) ⇒ Object



19
20
21
22
# File 'app/finders/crm/contacts_finder.rb', line 19

def self.counts_by_state(current_user, params = {})
  params = params.merge(sort: nil)
  new(current_user, params).execute.counts_by_state
end

Instance Method Details

#executeObject



29
30
31
32
33
34
35
36
37
# File 'app/finders/crm/contacts_finder.rb', line 29

def execute
  return CustomerRelations::Contact.none unless root_group

  contacts = root_group.contacts
  contacts = by_ids(contacts)
  contacts = by_state(contacts)
  contacts = by_search(contacts)
  sort_contacts(contacts)
end