activejob-trackable 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activejob/trackable/core.rb +9 -4
- data/lib/activejob/trackable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdcd73bc6f61e04156fb73a4f58fe5a6449dd34520af00ddd1bcb40d81a42c03
|
4
|
+
data.tar.gz: efbc64309d3dd2952041d91392b403d7e1319b30ac9ba9794f395698859ce38e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59aa7cdc87e52587eef23ad085d65fca2ca6a8e0f198caf7c5dafa91da727d01229216739c48bcfe80f6b1e63e03222c2e86aff51c0d3485b14d6211f9c14ab0
|
7
|
+
data.tar.gz: ae4b36ce3e45687b136df9ae0adde506eaa65588f23c9e90b19828931453843124b9532d1aa4142915ef1d29a1242e220adf707cfa60ff4e296ef0b66567e11b
|
@@ -119,22 +119,27 @@ module ActiveJob
|
|
119
119
|
def throttle
|
120
120
|
return yield unless throttled?
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
debounced_throttle(expires_in) { yield } || Rails.cache.fetch(key(*arguments), expires_in: expires_in) do
|
122
|
+
debounced_throttle { yield } || Rails.cache.fetch(key(*arguments), expires_in: expires_in) do
|
125
123
|
yield
|
126
124
|
|
127
125
|
true # put true into cache instead of serializing the job
|
128
126
|
end
|
129
127
|
end
|
130
128
|
|
131
|
-
def debounced_throttle
|
129
|
+
def debounced_throttle
|
132
130
|
return unless debounced? && tracker.persisted?
|
133
131
|
|
134
132
|
Rails.cache.write key(*arguments), true, expires_in: expires_in
|
135
133
|
|
136
134
|
yield
|
137
135
|
end
|
136
|
+
|
137
|
+
def expires_in
|
138
|
+
case trackable_options[:throttled]
|
139
|
+
when :daily then (Time.zone.at(scheduled_at).at_end_of_day - Time.current.to_f)
|
140
|
+
else trackable_options[:throttled] + (scheduled_at - Time.current.to_f)
|
141
|
+
end
|
142
|
+
end
|
138
143
|
end
|
139
144
|
end
|
140
145
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activejob-trackable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignatius Reza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|