db_subsetter 0.4.0 → 0.4.1

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: 3cbd626cd24132c2e8db14c89ecb66c300350886
4
- data.tar.gz: f7171ef20aded756e45b11a04c5072ab0303e1ec
3
+ metadata.gz: abf5990b7e3fd33ac74ba829e56919a5d6cc84c1
4
+ data.tar.gz: 3c83e352af29441d90675d8f1c924bdc80dfad14
5
5
  SHA512:
6
- metadata.gz: dd3d89c74237f6a7c942bfb72561e3eaef426e34c3919f1c0b6651287e76650bebec068eb1b5b81c1dcf2c0d7959c43e1b5682be51ba6f21b62234afab1d4107
7
- data.tar.gz: d9d8f8a4c5483e12fb9fe10cfee561c656fa67205c3968cc2c2cac6ca281ab7d76d9c8787b13534445434a0939f6477102ff7b2318c9e5e72effc282936280c1
6
+ metadata.gz: 0fb729b7e0db5e1de5133eaf082fb3e6067f4aaaa370b303a07c49d5a18bd3355f97a3a1ab43c3c41b508d470c9a126abac969d311c649fac9b0aa6bac23278e
7
+ data.tar.gz: f0637b18e81c8fb5414cac673b2f94d954bc8c10e1d7398ca8589c976069107ea22f5aff37d6aa7db7778f7173b76fc3056e6d3e0015931584c4f3d5d104ca0f
data/db_subsetter.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency "activerecord", "~> 4.2"
29
29
  spec.add_dependency "sqlite3", "~> 1.3"
30
- spec.add_dependency "random-word"
30
+ spec.add_dependency "random-word", "~> 1.3"
31
31
  end
32
32
 
@@ -55,6 +55,7 @@ module DbSubsetter
55
55
 
56
56
  def initialize
57
57
  @scramblers = []
58
+ @page_counts = {}
58
59
  end
59
60
 
60
61
  private
@@ -88,7 +89,7 @@ module DbSubsetter
88
89
  end
89
90
 
90
91
  def pages(table)
91
- ( filtered_row_count(table) / select_batch_size.to_f ).ceil
92
+ @page_counts[table] ||= ( filtered_row_count(table) / select_batch_size.to_f ).ceil
92
93
  end
93
94
 
94
95
  def order_by(table)
@@ -134,7 +135,9 @@ module DbSubsetter
134
135
  # Need to extend this to take more than the first batch_size records
135
136
  query = query.order(arel_table[order_by(table)]) if order_by(table)
136
137
 
137
- sql = query.skip(i * select_batch_size).take(select_batch_size).project( Arel.sql('*') ).to_sql
138
+
139
+ query = query.skip(i * select_batch_size).take(select_batch_size) if pages(table) > 1
140
+ sql = query.project( Arel.sql('*') ).to_sql
138
141
 
139
142
  records = ActiveRecord::Base.connection.select_rows( sql )
140
143
  records.each_slice(insert_batch_size) do |rows|
@@ -1,3 +1,3 @@
1
1
  module DbSubsetter
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_subsetter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Francis
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: random-word
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1.3'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1.3'
97
97
  description:
98
98
  email:
99
99
  - joe@lostapathy.com