culturecode_stagehand 0.7.1 → 0.7.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32aa6c36c7e088a7ced2a1ba65eb7bebf49403b0
|
4
|
+
data.tar.gz: c57ef59b9cd02ca2576e7360a57dd50285e24ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc7407c7a397721ffbf567d24a4917958b1a97ef6acbdb7d9a1828f875ca043cf5081fbb45b5190a5d2906d3f3ffc2bbc66fe6bc8b136e04798f0aa500067bd5
|
7
|
+
data.tar.gz: cc5115eb348fa1a58ab94835dfba2752d6f906fbe6b394f1a70a19963ee91bb33d183d440c74b31ded684589dd4e953ff1f2c02ad7a9b4996450353876a6b2d3
|
data/lib/stagehand/schema.rb
CHANGED
@@ -16,9 +16,10 @@ module Stagehand
|
|
16
16
|
t.string :session
|
17
17
|
end
|
18
18
|
|
19
|
-
add_index :stagehand_commit_entries, :commit_id
|
20
|
-
add_index :stagehand_commit_entries, :operation
|
21
|
-
add_index :stagehand_commit_entries, [:record_id, :table_name]
|
19
|
+
add_index :stagehand_commit_entries, :commit_id # Used for looking up all entries within a commit
|
20
|
+
add_index :stagehand_commit_entries, :operation # Mostly used for looking up start entries
|
21
|
+
add_index :stagehand_commit_entries, [:record_id, :table_name] # Used for 'matching' scope
|
22
|
+
add_index :stagehand_commit_entries, [:operation, :commit_id] # Used for 'not_in_progress' scope
|
22
23
|
|
23
24
|
# Create trigger to initialize session using a function
|
24
25
|
ActiveRecord::Base.connection.execute("DROP TRIGGER IF EXISTS stagehand_session_trigger;")
|
@@ -26,8 +26,13 @@ module Stagehand
|
|
26
26
|
scope :contained, lambda { where.not(:commit_id => nil) }
|
27
27
|
scope :not_in_progress, lambda {
|
28
28
|
joins("LEFT OUTER JOIN (#{ unscoped.select('session, MAX(id) AS start_id').uncontained.start_operations.group('session').to_sql }) AS active_starts
|
29
|
-
ON active_starts.session =
|
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
|
+
scope :with_uncontained_keys, lambda {
|
32
|
+
joins("LEFT OUTER JOIN (#{ unscoped.contained.select('record_id, table_name').to_sql}) AS contained
|
33
|
+
ON contained.record_id = #{table_name}.record_id AND contained.table_name = #{table_name}.table_name")
|
34
|
+
.where("contained.record_id IS NULL")
|
35
|
+
}
|
31
36
|
|
32
37
|
def self.matching(object)
|
33
38
|
keys = Array.wrap(object).collect {|entry| Stagehand::Key.generate(entry) }.compact
|
@@ -69,7 +69,7 @@ module Stagehand
|
|
69
69
|
offset = 0
|
70
70
|
|
71
71
|
while sessions.present?
|
72
|
-
autosyncable_entries(:session => sessions.shift(30)).offset(offset).limit(BATCH_SIZE).each do |entry|
|
72
|
+
autosyncable_entries(:session => sessions.shift(30)).offset(offset).limit(BATCH_SIZE).uniq(&:id).each do |entry|
|
73
73
|
with_confirmed_autosyncability(entry, &block)
|
74
74
|
end
|
75
75
|
offset += BATCH_SIZE
|
@@ -88,16 +88,10 @@ module Stagehand
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
# Returns commit entries in ID descending order
|
92
91
|
def autosyncable_entries(scope = nil)
|
93
|
-
entries = CommitEntry.content_operations.not_in_progress
|
94
|
-
|
95
|
-
|
96
|
-
subquery = CommitEntry.group('record_id, table_name').having('count(commit_id) = 0').where(scope)
|
97
|
-
entries = entries.joins("JOIN (#{subquery.select('MAX(id) AS max_id').to_sql}) subquery ON id = max_id")
|
98
|
-
end
|
99
|
-
|
100
|
-
return entries.order(:id => :desc)
|
92
|
+
entries = CommitEntry.content_operations.not_in_progress.where(scope).order(:id => :desc)
|
93
|
+
entries = entries.with_uncontained_keys unless Configuration.ghost_mode?
|
94
|
+
return entries
|
101
95
|
end
|
102
96
|
|
103
97
|
def sync_checklist(checklist)
|
data/lib/stagehand/version.rb
CHANGED
@@ -6,7 +6,8 @@ namespace :stagehand do
|
|
6
6
|
|
7
7
|
desc "Syncs records that don't need confirmation to production"
|
8
8
|
task :sync, [:limit] => :environment do |t, args|
|
9
|
-
|
9
|
+
limit = args[:limit].present? ? args[:limit].to_i : nil
|
10
|
+
Stagehand::Staging::Synchronizer.sync(limit)
|
10
11
|
end
|
11
12
|
|
12
13
|
desc "Syncs all records to production, including those that require confirmation"
|