statisfy 0.0.9 → 0.0.11

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: a41b2e365d8635fabfc742f25def7ac567eeff9e73f7e133f8b935fbd549d5fd
4
- data.tar.gz: 7ab00c9602030012aa8db20a021a0a868553b4824e667a6eee890e9f073f98cf
3
+ metadata.gz: 3e1e002d54e02e8717c8537367bca6135092525f33c8983aa9aef000df83b04a
4
+ data.tar.gz: 510fcff13694f65533c276431f6d0dc4f02c6b753bebd65716cb1b1c912047a7
5
5
  SHA512:
6
- metadata.gz: bf6f4c3038deea64ac641547e441a277e9c7d82bed9c4c89aef6cdb6209ce91308ac2603a1c13ce8a73767b8b72241fb11b88657968c5f41bef6636a352a9a43
7
- data.tar.gz: fd2ca239cd106501448b2615a26faebd67c45d3b1160ac52eaeef202edcf5ce3efa4d8fff6eb691b267803ea82eefbda5ecd56441c207cef4770f9953dbaabeb
6
+ metadata.gz: a6cdb0207adb660ac3bfde3fbd42f1f6e3aae762c12ab10941c6b944cecad7f4f49a5c4d5bfeb2c810bbf00fc51069a8c1fe72995ea50860d9ad1e6a2dcf61ca
7
+ data.tar.gz: 29fdcfa2010773fc5c4b4fbcb74863eaea47f4d191852b625196b15c8e572cd14ce609e2ec6a1849e3c548116e8d344ff836ce0dff3fa9e84637c2e458f36bd4
@@ -45,6 +45,7 @@ module Statisfy
45
45
  define_method(:decrement?, args[:decrement_if] || -> { false })
46
46
  define_method(:should_run?, args[:if] || -> { true })
47
47
  define_method(:decrement_on_destroy?, -> { args[:decrement_on_destroy] != false })
48
+ define_method(:month_to_set, args[:date_override] || -> { params["created_at"] })
48
49
  end
49
50
 
50
51
  #
@@ -172,10 +173,6 @@ module Statisfy
172
173
  scopes.flatten.compact << nil
173
174
  end
174
175
 
175
- def month_to_set
176
- params["created_at"].to_date.strftime("%Y-%m")
177
- end
178
-
179
176
  def process_event
180
177
  return decrement if can_decrement_on_destroy?
181
178
  return unless if_async
@@ -200,7 +197,7 @@ module Statisfy
200
197
  # (in general the Department(s) and Organisation(s) for both the current month and the global counter)
201
198
  #
202
199
  def all_counters
203
- [month_to_set, nil].each do |month|
200
+ [month_to_set.to_date.strftime("%Y-%m"), nil].each do |month|
204
201
  scopes_with_global.each do |scope|
205
202
  yield self.class.key_for(scope:, month:)
206
203
  end
@@ -22,7 +22,7 @@ module Statisfy
22
22
 
23
23
  if start_at.present? || scope&.created_at.present?
24
24
  start_at ||= scope.created_at
25
- n_months = (Time.zone.today.year + Time.zone.today.month) - (start_at.year + start_at.month)
25
+ n_months = (Time.zone.today.year * 12 + Time.zone.today.month) - (start_at.year * 12 + start_at.month)
26
26
  end
27
27
 
28
28
  relevant_months = (0..n_months).map do |i|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statisfy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Villeneuve