Class: ViewContact
- Inherits:
-
ApplicationViewRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationViewRecord
- ViewContact
- Includes:
- Models::SearchableView
- Defined in:
- app/models/view_contact.rb
Overview
== Schema Information
Table name: view_contacts
Database name: primary
id :integer primary key
city :string(255)
contact_roles :string(255) is an Array
country_iso3 :string(3)
customer_full_name :string(255)
do_not_contact :text
first_name :string(255)
full_name :string(255)
inactive :boolean
last_name :string(255)
middle_name :string(255)
primary_email :string(255)
primary_fax :string(255)
primary_phone :string(255)
primary_sales_rep_full_name :string(255)
state_code :string(20)
zip :string(255)
created_at :datetime
updated_at :datetime
customer_id :integer
primary_sales_rep_id :integer
Constant Summary collapse
- HAS_TOPIC_RESPONSE_SQL =
<<-EOS EXISTS( select 1 from party_topics pt inner join party_topics_topic_responses pttr on pttr.customer_topic_id = pt.id where pt.party_id = view_contacts.id and pttr.topic_response_id IN (?) ) EOS
Class Method Summary collapse
-
.contact_point_category_cont ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are contact point category cont.
-
.contact_point_cont ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are contact point cont.
-
.enrolled_in_spiff_id ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are enrolled in spiff id.
-
.has_one_of_these_topic_responses ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are has one of these topic responses.
-
.participated_in_spiff ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are participated in spiff.
- .ransackable_scopes(_auth_object = nil) ⇒ Object
Methods included from Models::SearchableView
#crm_link, #crm_link_subtitle, #has_columns?, #main_resource, #readonly?
Methods inherited from ApplicationViewRecord
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.contact_point_category_cont ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are contact point category cont. Active Record Scope
42 |
# File 'app/models/view_contact.rb', line 42 scope :contact_point_category_cont, ->(*categories) { where("EXISTS(select 1 from contact_points cp where cp.party_id = view_contacts.id and cp.category IN (?))", categories.flatten) } |
.contact_point_cont ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are contact point cont. Active Record Scope
41 |
# File 'app/models/view_contact.rb', line 41 scope :contact_point_cont, ->(detail) { where("EXISTS(select 1 from contact_points cp where cp.party_id = view_contacts.id and cp.detail ilike ?)", "%#{detail}%") } |
.enrolled_in_spiff_id ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are enrolled in spiff id. Active Record Scope
43 |
# File 'app/models/view_contact.rb', line 43 scope :enrolled_in_spiff_id, ->(sid) { where("EXISTS(select 1 from spiff_enrollments se where se.contact_id = view_contacts.id and se.spiff_id = ?)", sid) } |
.has_one_of_these_topic_responses ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are has one of these topic responses. Active Record Scope
45 |
# File 'app/models/view_contact.rb', line 45 scope :has_one_of_these_topic_responses, ->(topic_response_ids) { where(HAS_TOPIC_RESPONSE_SQL, [topic_response_ids].flatten.map(&:to_i) ) } |
.participated_in_spiff ⇒ ActiveRecord::Relation<ViewContact>
A relation of ViewContacts that are participated in spiff. Active Record Scope
44 |
# File 'app/models/view_contact.rb', line 44 scope :participated_in_spiff, ->(tf) { where("#{tf == 'true' ? ' ' : 'NOT '}EXISTS(select 1 from spiff_enrollments se where se.contact_id = view_contacts.id)") } |
.ransackable_scopes(_auth_object = nil) ⇒ Object
47 48 49 |
# File 'app/models/view_contact.rb', line 47 def self.ransackable_scopes(_auth_object = nil) super + %i[contact_point_cont contact_point_category_cont enrolled_in_spiff_id participated_in_spiff has_one_of_these_topic_responses] end |