chore: add alternative

This commit is contained in:
Shivam Mishra
2025-03-26 22:24:53 +05:30
parent 2c91577419
commit 92a04369e2
@@ -39,5 +39,12 @@ class Internal::RemoveOrphanedContactsService
def base_query
account.contacts.where('created_at < ?', Time.zone.now - offset)
# Alternative
# orphaned_contact_ids = account.contacts
# .left_outer_joins(:conversations)
# .where('contacts.created_at < ?', Time.zone.now - offset)
# .where(conversations: { id: nil }) # Select contacts with no conversations
# .pluck('contacts.id') # Get only the IDs
end
end