culturecode_stagehand 0.12.7 → 0.12.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stagehand/staging/commit_entry.rb +2 -1
- data/lib/stagehand/staging/synchronizer.rb +17 -9
- data/lib/stagehand/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 157594f1ea15ea034a9c883c00835b44bc6d6bef
|
4
|
+
data.tar.gz: f42ed40749d2ac477e5d3c064bc9bb306331a4e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6bfe97dcb0695d74e415dbaa74ab0d3e425027833fe4afb660ceb7f354db7a2c93ca3d2d1da58ae6fd95e66ceef86fc6891b41c1b675b3496692ff0618c2021
|
7
|
+
data.tar.gz: 2240f17970315f0fb0d7fd64f999bef1a6374903f190cbb01cefa0561edbcd18f87da879b8dedc012137045e02bf198e1f97fbcfb64a3eeea223f511c43ae688
|
@@ -29,7 +29,8 @@ module Stagehand
|
|
29
29
|
ON active_starts.session = #{table_name}.session AND active_starts.start_id <= #{table_name}.id")
|
30
30
|
.where("active_starts.start_id IS NULL") }
|
31
31
|
scope :with_uncontained_keys, lambda {
|
32
|
-
|
32
|
+
uncontained
|
33
|
+
.joins("LEFT OUTER JOIN (#{ unscoped.contained.select('record_id, table_name').distinct.to_sql}) AS contained
|
33
34
|
ON contained.record_id = #{table_name}.record_id AND contained.table_name = #{table_name}.table_name")
|
34
35
|
.where("contained.record_id IS NULL")
|
35
36
|
}
|
@@ -83,14 +83,12 @@ module Stagehand
|
|
83
83
|
# Lazily iterate through millions of commit entries
|
84
84
|
# Returns commit entries in ID descending order
|
85
85
|
def iterate_autosyncable_entries(&block)
|
86
|
-
max = CommitEntry.maximum(:id)
|
87
|
-
min = CommitEntry.minimum(:id)
|
86
|
+
max = CommitEntry.maximum(:id).to_i
|
87
|
+
min = CommitEntry.minimum(:id).to_i
|
88
88
|
|
89
89
|
max.step(min, -BATCH_SIZE).each do |current|
|
90
90
|
range = [current - BATCH_SIZE, min].max..current
|
91
|
-
autosyncable_entries(:id => range).
|
92
|
-
with_confirmed_autosyncability(entry, &block)
|
93
|
-
end
|
91
|
+
with_confirmed_autosyncability(autosyncable_entries(:id => range).order(:id => :desc), &block)
|
94
92
|
end
|
95
93
|
end
|
96
94
|
|
@@ -98,15 +96,25 @@ module Stagehand
|
|
98
96
|
# This confirmation is used to guard against writes to the record that occur after loading an initial list of
|
99
97
|
# entries that are autosyncable, but before the record is actually synced. To prevent this, a lock on the record
|
100
98
|
# is acquired and then the record's autosync eligibility is rechecked before calling the block.
|
101
|
-
def with_confirmed_autosyncability(
|
99
|
+
def with_confirmed_autosyncability(entries, &block)
|
100
|
+
entries = Array.wrap(entries)
|
101
|
+
return unless entries.present?
|
102
|
+
|
102
103
|
Database.transaction do
|
103
|
-
|
104
|
-
|
104
|
+
# Lock the records so nothing can update them
|
105
|
+
CommitEntry.connection.execute(CommitEntry.where(:id => entries).lock.to_sql)
|
106
|
+
|
107
|
+
# Execute the block for each entry we've confirm autosyncability
|
108
|
+
confirmed_ids = Set.new(autosyncable_entries.where(:id => entries).pluck(:id))
|
109
|
+
|
110
|
+
entries.each do |entry|
|
111
|
+
block.call(entry) if confirmed_ids.include?(entry.id)
|
112
|
+
end
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
108
116
|
def autosyncable_entries(scope = nil)
|
109
|
-
entries = CommitEntry.content_operations.not_in_progress.where(scope)
|
117
|
+
entries = CommitEntry.content_operations.not_in_progress.where(scope)
|
110
118
|
entries = entries.with_uncontained_keys unless Configuration.ghost_mode?
|
111
119
|
return entries
|
112
120
|
end
|
data/lib/stagehand/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: culturecode_stagehand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Jakobsen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-02-
|
12
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|