effective_mailchimp 0.8.1 → 0.9.0

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: 5cf2d88e8b2f00becc08815e465620acf595af2f94b2f4e17b181fdf3b31ab8c
4
- data.tar.gz: '09e182375468981d4011eb7719ab31fd958eec207b6d233aff869395d6b63c3c'
3
+ metadata.gz: 49ad10cd9354cfacf479287b2c4c08fcd3bd4423e09214cb51e0c3b6ccfd16eb
4
+ data.tar.gz: 26616852a4c2fd9234b08653e4ffc0c0997888b100f4865be25ea27dea1af6f3
5
5
  SHA512:
6
- metadata.gz: afd8bd97b2234900b447c395ddb6cef941b08b1bc3c611151732d6fd60ceedcb3741c7ac1452f05be4ac5293e81d31c017422285bb79980e9b6a68dbd6ecf9d0
7
- data.tar.gz: 14e816947972b23155640a57844d2e58a285208f0c013a40805f08ca5f9cce960ddd9b807300bcc874d8326e703f8eee3f05760e78fcbc8dd40b00a7d4d80c10
6
+ metadata.gz: 06fe791199da318312aeca0e0c674f75b73e4d85147ac062f1504cea7cf80586ccac15e1da0eff8755c82627c908b62f90c4bc2bad3aea414047373dd592bf07
7
+ data.tar.gz: 2967fdadbe7296ca9b2d4f39c7f50c6506f44f335bed45379abda8e503b3d49b15655bd5091041e8f56c18a0508613967a1c40aaffa8ed4d6e583e77b4a5860e
@@ -34,7 +34,8 @@ module EffectiveMailchimpUser
34
34
  }
35
35
 
36
36
  # The user updated the form
37
- after_commit(if: -> { mailchimp_member_update_required? }) do
37
+ after_commit(if: -> { mailchimp_member_update_required? }, unless: -> { EffectiveMailchimp.supressed? || @mailchimp_member_update_enqueued }) do
38
+ @mailchimp_member_update_enqueued = true
38
39
  EffectiveMailchimpUpdateJob.perform_later(self) # This calls user.mailchimp_update! on the background
39
40
  end
40
41
  end
@@ -123,7 +124,8 @@ module EffectiveMailchimpUser
123
124
  'CATEGORY': membership&.categories&.to_sentence,
124
125
  'STATUS': membership&.statuses&.to_sentence,
125
126
  'NUMBER': membership&.number,
126
- 'JOINED': membership&.joined_on&.strftime('%F')
127
+ 'JOINED': membership&.joined_on&.strftime('%F'),
128
+ 'FEESPAIDTO': mailchimp_membership_fees_paid_through_period()&.strftime('%F')
127
129
  )
128
130
  end
129
131
 
@@ -137,6 +139,29 @@ module EffectiveMailchimpUser
137
139
  atts
138
140
  end
139
141
 
142
+ # Returns the maximum fees_paid_through_period of the membership and any deferred membership_period fees
143
+ def mailchimp_membership_fees_paid_through_period
144
+ periods = []
145
+
146
+ # Find the fees_paid_through_period from any membership
147
+ if self.class.respond_to?(:effective_memberships_user?) && memberships.present?
148
+ membership = memberships.first() # Individual or organization membership
149
+ periods << membership&.fees_paid_through_period
150
+ end
151
+
152
+ # Find the fees_paid_through_period from any deferred membership fees
153
+ fees = if self.class.respond_to?(:effective_memberships_organization_user?) && organizations.present?
154
+ Effective::Fee.deferred.where(owner: [self, organizations])
155
+ else
156
+ Effective::Fee.deferred.where(owner: self)
157
+ end
158
+
159
+ periods += fees.select { |fee| fee.membership_period_fee? }.map(&:fees_paid_through_period)
160
+
161
+ # Return the maximum fees paid through period
162
+ periods.compact.max
163
+ end
164
+
140
165
  def mailchimp_subscribed_lists
141
166
  mailchimp_list_members.select(&:subscribed?).map(&:mailchimp_list)
142
167
  end
@@ -38,7 +38,7 @@ module Effective
38
38
  end
39
39
 
40
40
  def groups_url
41
- "https://#{server}.admin.mailchimp.com/lists/dashboard/groups/"
41
+ "https://#{server}.admin.mailchimp.com/audience/groups/"
42
42
  end
43
43
 
44
44
  def contacts_url
@@ -1,3 +1,3 @@
1
1
  module EffectiveMailchimp
2
- VERSION = '0.8.1'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -60,4 +60,20 @@ module EffectiveMailchimp
60
60
  [ :mailchimp_user_form_action, mailchimp_list_members_attributes: [:id, :mailchimp_list_id, :subscribed, interests: []] ]
61
61
  end
62
62
 
63
+ # Used to supress any background jobs during import processes
64
+ def self.supressed=(value)
65
+ Thread.current[:effective_mailchimp_supressed] = value
66
+ end
67
+
68
+ def self.supressed(&block)
69
+ Thread.current[:effective_mailchimp_supressed] = true
70
+ value = yield
71
+ Thread.current[:effective_mailchimp_supressed] = nil
72
+ value
73
+ end
74
+
75
+ def self.supressed?
76
+ Thread.current[:effective_mailchimp_supressed] == true
77
+ end
78
+
63
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_mailchimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-04 00:00:00.000000000 Z
11
+ date: 2024-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails