elastic_record 5.1.0 → 5.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbc183b9807acb14f1ba0b3d2f860c7be2eddbcf7360d542cbf9f1a9ea9df166
|
4
|
+
data.tar.gz: cbcb08f9fff903a87f0fa35b4f5ceb1542870ec1b176605e559eb99111f53b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4b87dc02cb1bd4f0db4fdd02923584b96137ad1c8b115f94c906244f66f77aa8f021721724333a14f33b15f950d1df57a863c566ee96265b00f5586509a784
|
7
|
+
data.tar.gz: ed8050784a85135ac6e3a9c650608e20d168221349bb84bc4b35588a474ac475b45f2e0605d358577f0b9147644c4254b303885db3153b8a169ef087b8ae4593
|
data/elastic_record.gemspec
CHANGED
@@ -2,12 +2,15 @@ module ElasticRecord
|
|
2
2
|
class Relation
|
3
3
|
module FinderMethods
|
4
4
|
def find(*ids)
|
5
|
-
ids
|
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;
|
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.
|
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-
|
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.
|
199
|
+
rubygems_version: 2.7.8
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: An Elasticsearch querying ORM
|