culturecode_stagehand 0.7.1 → 0.7.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d275b336114ac293617e2cf4466dc2d7ce98c3e
4
- data.tar.gz: 7846cb496845f2e46cc79a52e9f123f824e52089
3
+ metadata.gz: 32aa6c36c7e088a7ced2a1ba65eb7bebf49403b0
4
+ data.tar.gz: c57ef59b9cd02ca2576e7360a57dd50285e24ec2
5
5
  SHA512:
6
- metadata.gz: 1968350dfdabf2ef4fbdb3fd2f42d7d98b4e6f86bdb68a07b066850dc1a67d7de00d07c7c867a00b8ad801c6170d8879e386fbb71dd4d4b9f82d7fd71f1c57a3
7
- data.tar.gz: 123c82e038abf8453a4a802ae125ee88fdec7d1fd180241b068161a243f86fd8156cc93c05948b0f7874093ec79f5269884ff28e3e47a37ee1cb76b00c5d40c1
6
+ metadata.gz: fc7407c7a397721ffbf567d24a4917958b1a97ef6acbdb7d9a1828f875ca043cf5081fbb45b5190a5d2906d3f3ffc2bbc66fe6bc8b136e04798f0aa500067bd5
7
+ data.tar.gz: cc5115eb348fa1a58ab94835dfba2752d6f906fbe6b394f1a70a19963ee91bb33d183d440c74b31ded684589dd4e953ff1f2c02ad7a9b4996450353876a6b2d3
@@ -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 = stagehand_commit_entries.session AND active_starts.start_id <= stagehand_commit_entries.id")
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
- unless Configuration.ghost_mode?
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)
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
@@ -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
- Stagehand::Staging::Synchronizer.sync(args[:limit])
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"
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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen