elastic_record 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elastic_record.gemspec +1 -1
- data/lib/elastic_record/railtie.rb +0 -10
- data/lib/elastic_record/relation.rb +9 -2
- data/test/elastic_record/integration/active_record_test.rb +10 -4
- data/test/helper.rb +1 -2
- metadata +2 -4
- data/lib/elastic_record/integration/active_record.rb +0 -7
- data/lib/elastic_record/integration/cassandra_object.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f4401dda11a00875bd98fb93aa20968e6026db3
|
4
|
+
data.tar.gz: 0d1ec26e07c6138e08c1d6037a2f7a201e391031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d62018904effb980ea3b52f3de380324b37a559ad53eba9b833d1849d59fc35e9918a950f1d5a9eb519086ed3e59dcf1cd52beaa76739a88ce3cfae5536cbe26
|
7
|
+
data.tar.gz: 6d0860961a41249853a96366c8fcafef952c5ac367df43c09a59623e587d14837503f33628e43dff2925a0ae97bf98980a6a97a036c7518874ce41fda17fd456
|
data/elastic_record.gemspec
CHANGED
@@ -15,15 +15,5 @@ module ElasticRecord
|
|
15
15
|
include ElasticRecord::Railties::ControllerRuntime
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
initializer "elastic_record.orm" do |app|
|
20
|
-
ActiveSupport.on_load(:active_record) do
|
21
|
-
require 'elastic_record/integration/active_record'
|
22
|
-
end
|
23
|
-
|
24
|
-
ActiveSupport.on_load(:cassandra_object) do
|
25
|
-
require 'elastic_record/integration/cassandra_object'
|
26
|
-
end
|
27
|
-
end
|
28
18
|
end
|
29
19
|
end
|
@@ -41,8 +41,7 @@ module ElasticRecord
|
|
41
41
|
|
42
42
|
def to_a
|
43
43
|
@records ||= begin
|
44
|
-
|
45
|
-
records = scope.load_elastic_record_hits(to_ids)
|
44
|
+
records = load_hits(to_ids)
|
46
45
|
eager_load_associations(records) if eager_loading?
|
47
46
|
records
|
48
47
|
end
|
@@ -81,6 +80,14 @@ module ElasticRecord
|
|
81
80
|
@search_results ||= klass.elastic_index.search(as_elastic)
|
82
81
|
end
|
83
82
|
|
83
|
+
def load_hits(ids)
|
84
|
+
scope = select_values.any? ? klass.select(select_values) : klass
|
85
|
+
if defined?(ActiveRecord::Base) && klass < ActiveRecord::Base
|
86
|
+
scope = scope.order("FIELD(#{connection.quote_column_name(primary_key)}, #{ids.join(',')})")
|
87
|
+
end
|
88
|
+
scope.find(ids)
|
89
|
+
end
|
90
|
+
|
84
91
|
def eager_load_associations(records)
|
85
92
|
records = records.reject(&:marked_for_destruction?)
|
86
93
|
ids = records.map(&:id)
|
@@ -19,9 +19,9 @@ ActiveSupport.on_load :active_record do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
require 'elastic_record/integration/active_record'
|
23
22
|
class Project < ActiveRecord::Base
|
24
23
|
include ElasticRecord::Model
|
24
|
+
include ElasticRecord::Callbacks
|
25
25
|
|
26
26
|
self.elastic_index.mapping[:properties].update(
|
27
27
|
name: { type: 'string', index: 'not_analyzed' }
|
@@ -29,11 +29,17 @@ class Project < ActiveRecord::Base
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class ElasticRecord::ActiveRecordTest < MiniTest::Unit::TestCase
|
32
|
-
def
|
32
|
+
def setup
|
33
|
+
super
|
34
|
+
Project.elastic_index.create_and_deploy if Project.elastic_index.all_names.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_ordering
|
33
38
|
poo_product = Project.create! name: "Poo"
|
34
39
|
bear_product = Project.create! name: "Bear"
|
40
|
+
Project.elastic_index.refresh
|
35
41
|
|
36
|
-
assert_equal [
|
37
|
-
assert_equal [
|
42
|
+
assert_equal [bear_product, poo_product], Project.elastic_relation.order(name: 'asc')
|
43
|
+
assert_equal [poo_product, bear_product], Project.elastic_relation.order(name: 'desc')
|
38
44
|
end
|
39
45
|
end
|
data/test/helper.rb
CHANGED
@@ -24,9 +24,8 @@ module MiniTest
|
|
24
24
|
|
25
25
|
FakeWeb.clean_registry
|
26
26
|
|
27
|
-
Widget.elastic_index.create_and_deploy if Widget.elastic_index.all_names.empty?
|
28
|
-
|
29
27
|
ElasticRecord::Config.models.each do |model|
|
28
|
+
model.elastic_index.create_and_deploy if model.elastic_index.all_names.empty?
|
30
29
|
model.elastic_index.enable_deferring!
|
31
30
|
end
|
32
31
|
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: 1.1.
|
4
|
+
version: 1.1.6
|
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: 2013-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arelastic
|
@@ -67,8 +67,6 @@ files:
|
|
67
67
|
- lib/elastic_record/index/percolator.rb
|
68
68
|
- lib/elastic_record/index/settings.rb
|
69
69
|
- lib/elastic_record/index/warmer.rb
|
70
|
-
- lib/elastic_record/integration/active_record.rb
|
71
|
-
- lib/elastic_record/integration/cassandra_object.rb
|
72
70
|
- lib/elastic_record/log_subscriber.rb
|
73
71
|
- lib/elastic_record/lucene.rb
|
74
72
|
- lib/elastic_record/model.rb
|