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 +4 -4
- data/lib/statisfy/counter.rb +2 -5
- data/lib/statisfy/monthly.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e1e002d54e02e8717c8537367bca6135092525f33c8983aa9aef000df83b04a
|
4
|
+
data.tar.gz: 510fcff13694f65533c276431f6d0dc4f02c6b753bebd65716cb1b1c912047a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cdb0207adb660ac3bfde3fbd42f1f6e3aae762c12ab10941c6b944cecad7f4f49a5c4d5bfeb2c810bbf00fc51069a8c1fe72995ea50860d9ad1e6a2dcf61ca
|
7
|
+
data.tar.gz: 29fdcfa2010773fc5c4b4fbcb74863eaea47f4d191852b625196b15c8e572cd14ce609e2ec6a1849e3c548116e8d344ff836ce0dff3fa9e84637c2e458f36bd4
|
data/lib/statisfy/counter.rb
CHANGED
@@ -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
|
data/lib/statisfy/monthly.rb
CHANGED
@@ -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|
|