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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bee026ef1510c64a4ed85b498ef6ae7e3de81d7baf779ea396a79b21d15eaeac
4
- data.tar.gz: 9c449c533fa96c66fc3ab0b9f0960b2bc41425f0af6a457348fa97fdf415ee20
3
+ metadata.gz: fdcd73bc6f61e04156fb73a4f58fe5a6449dd34520af00ddd1bcb40d81a42c03
4
+ data.tar.gz: efbc64309d3dd2952041d91392b403d7e1319b30ac9ba9794f395698859ce38e
5
5
  SHA512:
6
- metadata.gz: 8364aa9547dd31acdd5cd192da9095052fbe68aa9e8b40d67eb76b43f66155acdc5b4edd67c00b5828ed3cf3a8aab07b4ee6b42e7c3aac2ef4fea85005bc59e0
7
- data.tar.gz: ef43d1e46a28aebf3cb6c1902f0f015b2e9547d9733450cc77ac5a2b84fc7d62fb751be0bbecf51951bf6456849f0de403cf98f6cd50f17f98991f44fb6e0002
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
- expires_in = trackable_options[:throttled] + (scheduled_at - Time.current.to_f)
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(expires_in)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Trackable
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  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.2
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-07 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails