trample_search 0.15.0 → 0.16.0

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: b54a2b004d66cc10b02800ca0c760f68f1f9eacf
4
- data.tar.gz: 3d6082f9e2ea2a5c84d68992313f10f91f299e23
3
+ metadata.gz: 20ffd69885c3eeda15f53ab9d4b6dd4bbc27f7be
4
+ data.tar.gz: 71f0bc852acc52e6cd9e3f71edc74336e26b0c85
5
5
  SHA512:
6
- metadata.gz: 5a0d96d4da55d0363a3d931e441d527c69024f058ae2326452ad8805e34aed2ceb3e072072822fc143e8267f40f77953f69529f0a7be50e3ffe0c8d7311069ee
7
- data.tar.gz: 4d7a070c1b741f277b8f13ff60c96d79f997ca40a60cc377ca3251d6285d40972883ecf223b554b88be8931749f385b991e29cb1292499abacbcb6cb5f0070d2
6
+ metadata.gz: 54309a47baec66899dc8e2481e37d3c4406394f8e8b86de457e084c468a352ce351b7988f0509daa6a46feab57f11d8975eea381efc5db53ed9642f8bfecaa63
7
+ data.tar.gz: 9c25d165d404140577558b19e5a9b776c5c55091f12a51ddb95ade05ea96293f299c24b7225d3935d9eb7c4dcbc567aa233e14005d1bab5a961626925f9d6c70
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://artifactory.dev.bloomberg.com:8080/artifactory/api/gems/rubygems/"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in trample.gemspec
4
4
  gemspec
@@ -9,6 +9,10 @@ module Trample
9
9
  attribute :total, Integer
10
10
  attribute :current_page, Integer, default: 1
11
11
  attribute :per_page, Integer, default: 20
12
+
13
+ def next?
14
+ (current_page * per_page) < total
15
+ end
12
16
  end
13
17
 
14
18
  class Sort
@@ -166,6 +166,23 @@ module Trample
166
166
  records
167
167
  end
168
168
 
169
+ #This implementation is not using scroll and scan of elastic
170
+ #https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
171
+ #In future versions we hope to replace this with elastic in-built implementation
172
+ #
173
+ def find_in_batches(batch_size: 10_000)
174
+ page_number = 1
175
+
176
+ loop do
177
+ paginate(size: batch_size, number: page_number)
178
+ query!
179
+ yield results
180
+ offset = metadata.pagination.current_page * metadata.pagination.per_page
181
+ break unless metadata.pagination.next?
182
+ page_number += 1
183
+ end
184
+ end
185
+
169
186
  private
170
187
 
171
188
  def deep_dup(o)
@@ -1,3 +1,3 @@
1
1
  module Trample
2
- VERSION = "0.15.0"
2
+ VERSION = "0.16.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trample_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - richmolj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus