Class: Maintenance::DuplicateCustomerContactPoints

Inherits:
Object
  • Object
show all
Defined in:
app/services/maintenance/duplicate_customer_contact_points.rb

Overview

Reports duplicate "category|detail" contact-point fingerprints per customer
(and per associated contact) for the recent (last-year) non-guest customer
cohort. Returns a hash like:

{
customer_id => ["email|x@y.z", { contact_id => ["phone|+1..."] }, ...]
}

Used by Maintenance::CustomerMaintenance#merge_duplicate_contact_points.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



14
15
16
# File 'app/services/maintenance/duplicate_customer_contact_points.rb', line 14

def self.call
  new.call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
# File 'app/services/maintenance/duplicate_customer_contact_points.rb', line 18

def call
  duplicates = {}
  Customer.where('created_at > ?', 1.year.ago).non_guests.find_each do |customer|
    merge_for_customer!(duplicates, customer)
  end
  duplicates
end