effective_mailchimp 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5e966f558a31774e2f2f1abc592ff6ebffa82a3efabe6aaad788e1542f17dec
4
- data.tar.gz: 989488ef3d77922963d03875421008c25a1b81f0013b008d82ebfc78d894b554
3
+ metadata.gz: b1080e126c3adae745b754f92a4d54345e6d7b758c26d0b3bb96848a6776fe5f
4
+ data.tar.gz: 1e9e4262626919069be09aabe1b22cae71a1347441f6b7dce5c8d03edbad8c27
5
5
  SHA512:
6
- metadata.gz: 11b18d328c459a1ee781a005ac806fb27336a4105cf169abe09958347d04b7f9b5ab11ec8a2d2e05facb6f5c6759afedb3e05e8e55a2184bc1b89f628ab75663
7
- data.tar.gz: 3594f9d6d2289be321208181b40cec8602f76d4d63e665e435749c68f3d962221dcbaca355550027f762b1c6d96fa18358584f4a4eaad7699e8da81d2c6c5d0f
6
+ metadata.gz: cc048e3944864ecb187be8855c010bdd50f87f85f97c7a59f9e6e44261a507ffc7e81a96eb08967a96a8b92a3bc37dc0da2cb7b666a3b980d51d2be34db49253
7
+ data.tar.gz: 6cf8f0e6d611bdf1d57c1ea2312588622cbb14f121039a94e8d336ee5ef9ad9f6b21abf7768fabc65057267538b14b262cd9648e141bae85094c4c98ca2969ed
@@ -0,0 +1,8 @@
1
+ class EffectiveMailchimpUpdateJob < ApplicationJob
2
+
3
+ def perform(user)
4
+ raise('expected an effective_mailchimp_user') unless user.class.try(:effective_mailchimp_user?)
5
+ user.mailchimp_update!(force: true)
6
+ end
7
+
8
+ end
@@ -26,7 +26,9 @@ module EffectiveMailchimpUser
26
26
  accepts_nested_attributes_for :mailchimp_lists, allow_destroy: true
27
27
 
28
28
  # The user updated the form
29
- after_commit(if: -> { mailchimp_user_form_action }) { mailchimp_update!(force: false) }
29
+ after_commit(if: -> { mailchimp_user_form_action }) do
30
+ EffectiveMailchimpUpdateJob.perform_later(self)
31
+ end
30
32
  end
31
33
 
32
34
  # Intended for app to extend
@@ -107,11 +109,13 @@ module EffectiveMailchimpUser
107
109
 
108
110
  return if lists.length == mailchimp_list_members.length && !(force || mailchimp_sync_required?)
109
111
 
110
- lists.each do |mailchimp_list|
111
- member = build_mailchimp_list_member(mailchimp_list: mailchimp_list)
112
+ Timeout::timeout(lists.length * 2) do
113
+ lists.each do |mailchimp_list|
114
+ member = build_mailchimp_list_member(mailchimp_list: mailchimp_list)
112
115
 
113
- list_member = api.list_member(mailchimp_list, email) || {}
114
- member.assign_mailchimp_attributes(list_member)
116
+ list_member = api.list_member(mailchimp_list, email) || {}
117
+ member.assign_mailchimp_attributes(list_member)
118
+ end
115
119
  end
116
120
 
117
121
  mailchimp_list_members.each do |member|
@@ -1,3 +1,3 @@
1
1
  module EffectiveMailchimp
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_mailchimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -197,6 +197,7 @@ files:
197
197
  - app/controllers/admin/mailchimp_lists_controller.rb
198
198
  - app/datatables/admin/effective_mailchimp_lists_datatable.rb
199
199
  - app/helpers/effective_mailchimp_helper.rb
200
+ - app/jobs/effective_mailchimp_update_job.rb
200
201
  - app/models/concerns/effective_mailchimp_user.rb
201
202
  - app/models/effective/mailchimp_api.rb
202
203
  - app/models/effective/mailchimp_list.rb