active_touch 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWI0YWQ1MmY3YjNjZDJlNzY1OWY5MmQ3OTI5Y2YxNGMwZGZkYWZmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWVjYzRkYTc2NjQyNmY0NTI3MDJlZmZhZmFkZmZkNzM2OGEwNGQ5Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2E2ZWVmNzc2MzFiMTA2MWE4ZjY0MTBhZTJjYjE0ZDk5ZGVjMzk4YjEyNmI2
|
10
|
+
N2Q3ZGFmN2I3OGNlZTFkMTc3ZDAwYjNlYWJlNGJlNjRkMGYzMjcyOGQyZmYx
|
11
|
+
MDUzMzkzOGJkNWJkZGM1ZDg5OTIzZDBmOGEyNWQ1N2UyYTQxYzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTNmOWIyZDM2MTQyMGY0ODEwMjRlM2M1OTU1Y2E1NTI4ZTZiOGQyNDU3MmNj
|
14
|
+
YTI3MjJjMmFmZmI4NjE1ZDkxOWVlMTIwOTY5MzExMmRjYjk2MjFmYzhlZmJk
|
15
|
+
Y2M2OTllZGEwMTkzYmExODJhYzIyNWM3ZmViOGE4MTc5OWVlM2Q=
|
data/Gemfile.lock
CHANGED
@@ -13,13 +13,17 @@ module ActiveTouch
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Configuration
|
16
|
-
attr_accessor :async, :batch_size, :ignored_attributes,
|
16
|
+
attr_accessor :associated_touch_delay, :async, :batch_process, :batch_size, :ignored_attributes,
|
17
|
+
:queue, :touch_process
|
17
18
|
|
18
19
|
def initialize
|
20
|
+
@associated_touch_delay = 0
|
19
21
|
@async = false
|
22
|
+
@batch_process = true
|
20
23
|
@batch_size = 100
|
21
24
|
@ignored_attributes = [:updated_at]
|
22
25
|
@queue = 'default'
|
26
|
+
@touch_process = :batch_synchronous
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveTouch
|
2
2
|
class TouchJob < ActiveJob::Base
|
3
3
|
|
4
|
-
def perform(record, association, after_touch, is_async =
|
4
|
+
def perform(record, association, after_touch, is_async = ActiveTouch.configuration.async)
|
5
5
|
associated = association == 'self' ? record : record.send(association)
|
6
6
|
|
7
7
|
if associated.is_a? ActiveRecord::Base
|
@@ -10,10 +10,28 @@ module ActiveTouch
|
|
10
10
|
|
11
11
|
elsif !associated.nil?
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
case ActiveTouch.configuration.touch_process
|
14
|
+
|
15
|
+
when :batch_synchronous
|
16
|
+
0.step(associated.count, ActiveTouch.configuration.batch_size).each do |offset|
|
17
|
+
batch = associated.offset(offset).limit(ActiveTouch.configuration.batch_size)
|
18
|
+
batch.update_all(updated_at: record.updated_at)
|
19
|
+
batch.each { |associate| associate.send(after_touch) } unless after_touch.blank?
|
20
|
+
end
|
21
|
+
|
22
|
+
when :non_batch_asynchronous
|
23
|
+
associated.each do |associate|
|
24
|
+
TouchJob
|
25
|
+
.set(
|
26
|
+
queue: ActiveTouch.configuration.queue,
|
27
|
+
wait: ActiveTouch.configuration.associated_touch_delay.seconds
|
28
|
+
)
|
29
|
+
.perform_later(associate, 'self', after_touch, is_async)
|
30
|
+
end
|
31
|
+
|
32
|
+
when :non_batch_synchronous
|
33
|
+
associated.update_all(updated_at: record.updated_at)
|
34
|
+
associated.each { |associate| associate.send(after_touch) } unless after_touch.blank?
|
17
35
|
end
|
18
36
|
end
|
19
37
|
end
|
data/lib/active_touch/version.rb
CHANGED
@@ -3,6 +3,10 @@ ActiveTouch.configure do |config|
|
|
3
3
|
# Default is false
|
4
4
|
# config.async = false
|
5
5
|
|
6
|
+
# Enable batch processing for large groups of records
|
7
|
+
# Default is false
|
8
|
+
# config.batch_processing = false
|
9
|
+
|
6
10
|
# Batch size of records to touch at a time
|
7
11
|
# Default is 100
|
8
12
|
# config.batch_size = 100
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_touch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Pheasey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|