Class: MassSearch::CustomerAssignToAudienceWorker
- Inherits:
-
Object
- Object
- MassSearch::CustomerAssignToAudienceWorker
- Includes:
- Sidekiq::Job, Sidekiq::Status::Worker
- Defined in:
- app/workers/mass_search/customer_assign_to_audience_worker.rb
Overview
Assigns selected Customers to an existing Audience in the background.
action_params: { audience_id: }
Instance Method Summary collapse
-
#perform(args = {}) ⇒ Object
Runs the job.
Instance Method Details
#perform(args = {}) ⇒ Object
Runs the job.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/workers/mass_search/customer_assign_to_audience_worker.rb', line 15 def perform(args = {}) search = Search.find(args[:search_id]) CurrentScope.locale = args[:locale]&.to_sym || :en params = (args[:action_params] || {}).with_indifferent_access audience = Audience.find(params[:audience_id]) customer_ids = search.pinned_query.filter_map(&:resource_id).uniq result = Campaign::AssignCustomersToAudience.new.process(audience, customer_ids) if result.subscribed? store info_message: result..to_sentence, redirect_to: Rails.application.routes.url_helpers.search_path(search.id) else store error_message: result..to_sentence, redirect_to: Rails.application.routes.url_helpers.search_path(search.id) end end |