Class: Marketing::CustomerMatch::AudienceRemoval
- Inherits:
-
Object
- Object
- Marketing::CustomerMatch::AudienceRemoval
- Defined in:
- app/services/marketing/customer_match/audience_removal.rb
Overview
Daily counterpart to AudienceSync: removes members who must no longer be in
ANY Customer Match list — opted out ("take me off your list"), closed,
bankrupt, guest, or inactive (Customer.marketing_suppressed, the exact
complement of the eligible+consented set the sync ingests). Reusing the
deterministic MemberBuilder means the removal reproduces exactly the
identifiers that were uploaded; removing a non-member is a no-op, so the same
suppressed set is removed from every list, statelessly.
Defaults to validate_only; a live run is opt-in (the daily schedule passes
validate_only: false).
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Result
-
#initialize(validate_only: true, client: Client.new) ⇒ AudienceRemoval
constructor
A new instance of AudienceRemoval.
Constructor Details
#initialize(validate_only: true, client: Client.new) ⇒ AudienceRemoval
Returns a new instance of AudienceRemoval.
33 34 35 36 |
# File 'app/services/marketing/customer_match/audience_removal.rb', line 33 def initialize(validate_only: true, client: Client.new) @validate_only = validate_only @client = client end |
Class Method Details
.call ⇒ Result
29 |
# File 'app/services/marketing/customer_match/audience_removal.rb', line 29 def self.call(**) = new(**).call |
Instance Method Details
#call ⇒ Result
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/services/marketing/customer_match/audience_removal.rb', line 39 def call removed = 0 requests = 0 MemberBuilder.new(Customer.marketing_suppressed).each_batch do |batch| list_ids.each do |list_id| @client.remove(user_list_id: list_id, members: batch, validate_only: @validate_only) requests += 1 end removed += batch.size end Result.new(removed:, lists: list_ids.size, requests:, validate_only: @validate_only) end |