elastic_record 5.1.0 → 5.2.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
  SHA256:
3
- metadata.gz: bb2dad78eb2851499ca2b7099f7774d79c375b5a180001bd612113353dfba33c
4
- data.tar.gz: ff1262c6527d45f1e9b0e8eb46e24dc881cdb10b5cb51b93e40f72f5a2f366dc
3
+ metadata.gz: fbc183b9807acb14f1ba0b3d2f860c7be2eddbcf7360d542cbf9f1a9ea9df166
4
+ data.tar.gz: cbcb08f9fff903a87f0fa35b4f5ceb1542870ec1b176605e559eb99111f53b72
5
5
  SHA512:
6
- metadata.gz: b1c4fab2b261935713156c78ebf2fd675a7a7b107ac5a415a25dd20c8364690492f566d82b4685e9c223818abafbaf21ef2083d89ad3ad1e2a60bb93ed150685
7
- data.tar.gz: 8f9d7ad4d081fe9096c65872c8b0e4fd0c2d4a3fa2df79bd7a8a8a3975fd7a7055c48b664a5f47beb2b7fcea07020e542f64b4f64e188c125e66c27ee11ad70f
6
+ metadata.gz: da4b87dc02cb1bd4f0db4fdd02923584b96137ad1c8b115f94c906244f66f77aa8f021721724333a14f33b15f950d1df57a863c566ee96265b00f5586509a784
7
+ data.tar.gz: ed8050784a85135ac6e3a9c650608e20d168221349bb84bc4b35588a474ac475b45f2e0605d358577f0b9147644c4254b303885db3153b8a169ef087b8ae4593
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '5.1.0'
5
+ s.version = '5.2.0'
6
6
  s.summary = 'An Elasticsearch querying ORM'
7
7
  s.description = 'Find your records with Elasticsearch'
8
8
 
@@ -2,12 +2,15 @@ module ElasticRecord
2
2
  class Relation
3
3
  module FinderMethods
4
4
  def find(*ids)
5
- ids = ids.flatten
5
+ return [] if ids.first.is_a?(Array) && ids.first.empty?
6
+ ids = ids.flatten
7
+ id_filter = filter(arelastic.filter.ids(ids))
8
+ id_filter = id_filter.limit(ids.size) unless limit_value
9
+
6
10
  case ids.size
7
11
  when 0; raise ActiveRecord::RecordNotFound.new('empty argument')
8
- when 1; filter(arelastic.filter.ids(ids)).first!
9
- else
10
- filter(arelastic.filter.ids(ids))
12
+ when 1; id_filter.first!
13
+ else id_filter
11
14
  end
12
15
  end
13
16
 
@@ -16,6 +16,12 @@ class ElasticRecord::Relation::FinderMethodsTest < MiniTest::Test
16
16
  end
17
17
  end
18
18
 
19
+ def test_find_exceed_default_limit
20
+ widgets = ('a'..'l').map {|color| Widget.create(color: color) }
21
+ assert_equal 12, Widget.elastic_relation.find(widgets.map(&:id)).size
22
+ assert_equal 11, Widget.elastic_relation.limit(11).find(widgets.map(&:id)).size
23
+ end
24
+
19
25
  def test_find_passed_an_array
20
26
  assert_equal 2, Widget.elastic_relation.find([@red_widget.id, @blue_widget.id]).size
21
27
  assert_equal 2, Widget.elastic_relation.filter('color' => ['red', 'blue']).find([@red_widget.id, @blue_widget.id]).size
@@ -23,6 +29,7 @@ class ElasticRecord::Relation::FinderMethodsTest < MiniTest::Test
23
29
  end
24
30
 
25
31
  def test_find_passed_an_empty_args
32
+ assert_equal [], Widget.elastic_relation.find([])
26
33
  assert_raises ActiveRecord::RecordNotFound do
27
34
  Widget.elastic_relation.find
28
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infogroup
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-24 00:00:00.000000000 Z
12
+ date: 2018-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: 1.8.11
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.7.6
199
+ rubygems_version: 2.7.8
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: An Elasticsearch querying ORM