culturecode_stagehand 0.13.4 → 0.14.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36834ff03b03124d75cbdcf9705e22e9ad76b12a
4
- data.tar.gz: e12e718f0adaf192a16ccfb51e9f4d36ffd54f52
3
+ metadata.gz: 5a2a6a3a01c856120842f041db2e36a5193513d4
4
+ data.tar.gz: f805ae100d46bd539e53bb2b611cb2a8c520b343
5
5
  SHA512:
6
- metadata.gz: 3781b0fb8eb9f013d15a2de73fb5a2a1b3b4dda9c42b09744688a87fd7504f176af38c46cbc6077bbc7cc2e1b92f7b0278191294557bb943817327e00bc4f4f4
7
- data.tar.gz: e9305cfcbd35587d1fcf70f9e4d54f55ccd14a52aa4adc5bfd4eb26d7c5d64471a5a45ea0f64a3742e6d295e4e501b153196db4f1aced4ae9694f549b447f46a
6
+ metadata.gz: 48fc4eeb89f87e4be85eca8da20829ce088b6684094b633d5b2f6751b3a0725ad3edb93db1b0eb7335eeef99993a0f11040cc374fcbd3a31dea98f0426f0cfe8
7
+ data.tar.gz: 6688e3bcfa1776c98280f6ac4a33898f99365c50d2763683eb7cf0e36773dc65c5a4088ed6f218a69a1ee542004ee0055dc4e45d87a1c7ee6ec2b50ec1a5affd
@@ -28,11 +28,22 @@ module Stagehand
28
28
  print "\nChecking #{table_name} "
29
29
  mismatched = {}
30
30
  limit = 1000
31
- index = 0
31
+
32
+ min_id = [
33
+ Database.staging_connection.select_value("SELECT MIN(id) FROM #{table_name}").to_i,
34
+ Database.production_connection.select_value("SELECT MIN(id) FROM #{table_name}").to_i
35
+ ].min
36
+
37
+ index = min_id / limit
38
+
39
+ max_id = [
40
+ Database.staging_connection.select_value("SELECT MAX(id) FROM #{table_name}").to_i,
41
+ Database.production_connection.select_value("SELECT MAX(id) FROM #{table_name}").to_i
42
+ ].max
32
43
 
33
44
  loop do
34
- production_records = Database.production_connection.select_all("SELECT * FROM #{table_name} LIMIT #{limit} OFFSET #{limit * index}")
35
- staging_records = Database.staging_connection.select_all("SELECT * FROM #{table_name} LIMIT #{limit} OFFSET #{limit * index}")
45
+ production_records = Database.production_connection.select_all("SELECT * FROM #{table_name} WHERE id BETWEEN #{limit * index} AND #{limit * (index + 1)}")
46
+ staging_records = Database.staging_connection.select_all("SELECT * FROM #{table_name} WHERE id BETWEEN #{limit * index} AND #{limit * (index + 1)}")
36
47
  id_column = production_records.columns.index('id')
37
48
 
38
49
  production_differences = production_records.rows - staging_records.rows
@@ -54,7 +65,8 @@ module Stagehand
54
65
  end
55
66
 
56
67
  index += 1
57
- break unless staging_records.present? || production_records.present?
68
+
69
+ break if index * limit > max_id
58
70
  end
59
71
 
60
72
  if mismatched.present?
@@ -9,7 +9,12 @@ module Stagehand
9
9
  all.select(&:empty?)
10
10
  end
11
11
 
12
+ def self.capturing?
13
+ !!@capturing
14
+ end
15
+
12
16
  def self.capture(subject_record = nil, except: [], &block)
17
+ @capturing = true
13
18
  start_operation = start_commit(subject_record)
14
19
  init_session!(start_operation)
15
20
 
@@ -21,6 +26,8 @@ module Stagehand
21
26
  else
22
27
  return end_commit(start_operation, except)
23
28
  end
29
+ ensure
30
+ @capturing = false
24
31
  end
25
32
 
26
33
  def self.containing(record)
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.13.4"
2
+ VERSION = "0.14.0"
3
3
  end
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.13.4
4
+ version: 0.14.0
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-06-28 00:00:00.000000000 Z
12
+ date: 2017-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails