Class: Crm::ContactsFinder
- Inherits:
-
Object
- Object
- Crm::ContactsFinder
- Includes:
- Gitlab::Allowable, Gitlab::Utils::StrongMemoize
- Defined in:
- app/finders/crm/contacts_finder.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user, params = {}) ⇒ ContactsFinder
constructor
A new instance of ContactsFinder.
Methods included from Gitlab::Allowable
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_user ⇒ Object (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 |
#params ⇒ Object (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
#execute ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/finders/crm/contacts_finder.rb', line 29 def execute group = params[:group]&.crm_group return CustomerRelations::Contact.none unless group && can?(@current_user, :read_crm_contact, group) contacts = group.contacts contacts = by_ids(contacts) contacts = by_state(contacts) contacts = by_search(contacts) sort_contacts(contacts) end |