diff --git a/app/jobs/mailchimp_supporter_sync_job.rb b/app/jobs/mailchimp_supporter_sync_job.rb new file mode 100644 index 00000000..557c9368 --- /dev/null +++ b/app/jobs/mailchimp_supporter_sync_job.rb @@ -0,0 +1,7 @@ +class MailchimpSupporterSyncJob < ApplicationJob + queue_as :default + + def perform(np_id, supporter_ids, tag_data) + Mailchimp.sync_supporters_to_list_from_tag_joins(np_id, supporter_ids, tag_data) + end +end diff --git a/lib/insert/insert_tag_joins.rb b/lib/insert/insert_tag_joins.rb index a7286ee4..672d4ba4 100644 --- a/lib/insert/insert_tag_joins.rb +++ b/lib/insert/insert_tag_joins.rb @@ -81,7 +81,7 @@ module InsertTagJoins # activities = Psql.execute( Qexpr.new.insert(:activities, activity_data) ) # Sync mailchimp lists, if present - Mailchimp.delay.sync_supporters_to_list_from_tag_joins(np_id, supporter_ids, tag_data) + MailchimpSupporterSyncJob.perform_later(np_id, supporter_ids, tag_data) { json: { inserted_count: tags.count, removed_count: deleted.count }, status: :ok } end