using batch of 20 to prevent timeouts
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
class MailChimpBatchUpdate
|
class MailChimpBatchUpdate
|
||||||
def self.update_all(api_key, list_id)
|
def self.update_all(api_key, list_id)
|
||||||
subscribers = []
|
subscribers = []
|
||||||
Supporter.each do |supporter|
|
mailchimp = Mailchimp::API.new(api_key)
|
||||||
|
|
||||||
|
Supporter.each_with_index do |supporter, index|
|
||||||
subscribers.push(subscriber supporter)
|
subscribers.push(subscriber supporter)
|
||||||
|
if index.modulo(20) == 0
|
||||||
|
mailchimp.lists.batch_subscribe(list_id, subscribers, false, true, false)
|
||||||
|
subscribers = []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mailchimp = Mailchimp::API.new(api_key)
|
|
||||||
mailchimp.lists.batch_subscribe(list_id, subscribers, false, true, false)
|
mailchimp.lists.batch_subscribe(list_id, subscribers, false, true, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user