mebla 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mebla (1.1.4)
4
+ mebla (1.1.5)
5
5
  mebla
6
6
  mongoid (~> 2.0.1)
7
7
  slingshot-rb (= 0.0.8)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 1.1.6
@@ -20,39 +20,36 @@ module Mebla
20
20
  @total = response['hits']['total']
21
21
 
22
22
  # Be efficient only query the database once
23
- model_ids = {}
23
+ model_ids = []
24
24
 
25
25
  # Collect results' ids
26
26
  response['hits']['hits'].each do |hit|
27
27
  model_class = hit['_type'].camelize.constantize
28
-
28
+ model_ids << [model_class]
29
+
29
30
  if model_class.embedded?
30
- unless model_ids[model_class]
31
- model_ids[model_class] = {}
32
- end
31
+ model_class_collection = model_ids.assoc(model_class)
33
32
  # collect parent ids
34
33
  # {class => {parent_id => [ids]}}
35
34
  parent_id = hit['_source']['_parent']
36
35
 
37
- unless model_ids[model_class][parent_id]
38
- model_ids[model_class][parent_id] = []
39
- end
36
+ model_class_collection << [parent_id]
40
37
 
41
- model_ids[model_class][parent_id].push hit['_source']['id']
38
+ model_class_collection.assoc(parent_id) << hit['_source']['id']
42
39
  else
43
- unless model_ids[model_class]
44
- model_ids[model_class] = []
45
- end
46
40
  # collect ids
47
41
  # {class => [ids]}
48
- model_ids[model_class] << hit['_source']['id']
42
+ model_ids.assoc(model_class) << hit['_source']['id']
49
43
  end
50
44
  end
51
45
 
52
46
  # Cast the results into their appropriate classes
53
47
  @entries = []
54
48
 
55
- model_ids.each_pair do |model_class, ids|
49
+ model_ids.each do |model_class_collection|
50
+ model_class = model_class_collection.first
51
+ ids = model_class_collection.drop(1)
52
+
56
53
  unless model_class.embedded?
57
54
  # Retrieve the results from the database
58
55
  @entries += model_class.any_in(:_id => ids).entries
@@ -61,7 +58,10 @@ module Mebla
61
58
  parent_class = model_class.embedded_parent
62
59
  access_method = model_class.embedded_as
63
60
 
64
- ids.each_pair do |parent_id, entries_ids|
61
+ ids.each do |parent_id_collection|
62
+ parent_id = parent_id_collection.first
63
+ entries_ids = parent_id_collection.drop(1)
64
+
65
65
  parent = parent_class.find parent_id
66
66
 
67
67
  # Retrieve the results from the database
data/lib/mebla/search.rb CHANGED
@@ -191,7 +191,7 @@ module Mebla
191
191
  # Log search query
192
192
  Mebla.log("Searching:\n#{@slingshot_search.to_json.to_s}", :debug)
193
193
  response = @slingshot_search.perform.json
194
- Mebla.log("Response:\n#{response}", :info)
194
+ Mebla.log("Response:\n#{response.to_json.to_s}", :info)
195
195
  @results = Mebla::ResultSet.new(response)
196
196
  # Log results statistics
197
197
  Mebla.log("Searched for:\n#{@slingshot_search.to_json.to_s}\ngot #{@results.total} documents in #{@results.time} ms", :debug)
data/mebla.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mebla}
8
- s.version = "1.1.5"
8
+ s.version = "1.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Omar Mekky"]
12
- s.date = %q{2011-05-24}
12
+ s.date = %q{2011-05-25}
13
13
  s.description = %q{
14
14
  An elasticsearch wrapper for mongoid odm based on slingshot. Makes integration between ElasticSearch full-text
15
15
  search engine and Mongoid documents seemless and simple.
@@ -127,6 +127,16 @@ Gem::Specification.new do |s|
127
127
  s.add_development_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
128
128
  s.add_development_dependency(%q<database_cleaner>, ["= 0.6.4"])
129
129
  s.add_development_dependency(%q<bluecloth>, ["~> 2.1.0"])
130
+ s.add_development_dependency(%q<bson>, ["~> 1.3.0"])
131
+ s.add_development_dependency(%q<bson_ext>, ["~> 1.3.0"])
132
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
133
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
134
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
135
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
136
+ s.add_development_dependency(%q<rcov>, [">= 0"])
137
+ s.add_development_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
138
+ s.add_development_dependency(%q<database_cleaner>, ["= 0.6.4"])
139
+ s.add_development_dependency(%q<bluecloth>, ["~> 2.1.0"])
130
140
  s.add_runtime_dependency(%q<slingshot-rb>, ["= 0.0.8"])
131
141
  s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.1"])
132
142
  s.add_development_dependency(%q<bson>, ["~> 1.3.0"])
@@ -187,6 +197,16 @@ Gem::Specification.new do |s|
187
197
  s.add_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
188
198
  s.add_dependency(%q<database_cleaner>, ["= 0.6.4"])
189
199
  s.add_dependency(%q<bluecloth>, ["~> 2.1.0"])
200
+ s.add_dependency(%q<bson>, ["~> 1.3.0"])
201
+ s.add_dependency(%q<bson_ext>, ["~> 1.3.0"])
202
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
203
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
204
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
205
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
206
+ s.add_dependency(%q<rcov>, [">= 0"])
207
+ s.add_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
208
+ s.add_dependency(%q<database_cleaner>, ["= 0.6.4"])
209
+ s.add_dependency(%q<bluecloth>, ["~> 2.1.0"])
190
210
  s.add_dependency(%q<slingshot-rb>, ["= 0.0.8"])
191
211
  s.add_dependency(%q<mongoid>, ["~> 2.0.1"])
192
212
  s.add_dependency(%q<bson>, ["~> 1.3.0"])
@@ -248,6 +268,16 @@ Gem::Specification.new do |s|
248
268
  s.add_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
249
269
  s.add_dependency(%q<database_cleaner>, ["= 0.6.4"])
250
270
  s.add_dependency(%q<bluecloth>, ["~> 2.1.0"])
271
+ s.add_dependency(%q<bson>, ["~> 1.3.0"])
272
+ s.add_dependency(%q<bson_ext>, ["~> 1.3.0"])
273
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
274
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
275
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
276
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
277
+ s.add_dependency(%q<rcov>, [">= 0"])
278
+ s.add_dependency(%q<mongoid-rspec>, ["= 1.4.1"])
279
+ s.add_dependency(%q<database_cleaner>, ["= 0.6.4"])
280
+ s.add_dependency(%q<bluecloth>, ["~> 2.1.0"])
251
281
  s.add_dependency(%q<slingshot-rb>, ["= 0.0.8"])
252
282
  s.add_dependency(%q<mongoid>, ["~> 2.0.1"])
253
283
  s.add_dependency(%q<bson>, ["~> 1.3.0"])