From 400feb4388e864cabf41ff7f1a5cf5fed3f9cecd Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Tue, 25 Mar 2025 18:53:32 +0530 Subject: [PATCH] feat: move resolved contacts to a scope --- app/models/contact.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index fca06fa9e..2caeea4cf 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -68,6 +68,8 @@ class Contact < ApplicationRecord enum contact_type: { visitor: 0, lead: 1, customer: 2 } + scope :resolved_contacts, -> { where("contacts.email <> '' OR contacts.phone_number <> '' OR contacts.identifier <> ''") } + scope :order_on_last_activity_at, lambda { |direction| order( Arel::Nodes::SqlLiteral.new( @@ -164,10 +166,6 @@ class Contact < ApplicationRecord } end - def self.resolved_contacts - where("contacts.email <> '' OR contacts.phone_number <> '' OR contacts.identifier <> ''") - end - def discard_invalid_attrs phone_number_format email_format