entity_store 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 97880958b956196cf02002393b06adf365a1bfba
4
- data.tar.gz: 06471d12f5bacc7f5ad7409c2bf0ffa3e336b1aa
3
+ metadata.gz: e43b6eb661aca44b6787f609047b1d26a8f7ce35
4
+ data.tar.gz: 1539522bfe305d04047a248b2b9fce12847fe163
5
5
  SHA512:
6
- metadata.gz: 85747f4ddb273c8b9f80430445cf5100b92ebd136a4ba1e1d2a7e7017357057fbe14996cdb76d45d296958d849f9aa8eab3ec442f5397ff85ca70914ffe7e2b1
7
- data.tar.gz: 2d1e8c46d5480b12a52b857ee1469d5a857f63ef27f6fde2c890b735c9bd08af312ef4341c7abe75ac3e61570f9cd246966240ba4ff3d3bacf0543655f84e7cf
6
+ metadata.gz: 46d856ef7e4ca152fe3859da3563ac5f33f15fca7805d42b86b4c3e2536ee4dcd1df1c6779b19c13daeea7983d2b62c31d2e9538c7adbe0e90436d6dec0345ee
7
+ data.tar.gz: 6de4e6ae68378f4f3e4083fd7723ff1447722afe2f36fb377f5a4cdb5d9d6281457c08a2000868a1b2c886d1c0f1bedb2753a18100df7e9d20f62dbd31100e66
@@ -53,4 +53,4 @@ module EntityStore
53
53
  "<#{self.class.name} #{self.attributes.inspect}>"
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -161,19 +161,30 @@ module EntityStore
161
161
 
162
162
  query = { '$or' => query_items }
163
163
 
164
- options = {
165
- :sort => [['entity_version', Mongo::ASCENDING], ['_id', Mongo::ASCENDING]]
166
- }
167
-
168
164
  result = Hash[ criteria.map { |item| [ item[:id], [] ] } ]
169
165
 
170
- events.find(query, options).each do |attrs|
171
- begin
172
- result[attrs['_entity_id'].to_s] << EntityStore::Config.load_type(attrs['_type']).new(attrs)
173
- rescue => e
174
- log_error "Error loading type #{attrs['_type']}", e
166
+ events.find(query).each do |attrs|
167
+ result[attrs['_entity_id'].to_s] << attrs
168
+ end
169
+
170
+ result.each do |id, events|
171
+ # Have to do the sort client side as otherwise the query will not use
172
+ # indexes (http://docs.mongodb.org/manual/reference/operator/query/or/#or-and-sort-operations)
173
+ events.sort_by! { |attrs| [attrs['entity_version'], attrs['_id']] }
174
+
175
+ # Convert the attributes into event objects
176
+ events.map! do |attrs|
177
+ begin
178
+ EntityStore::Config.load_type(attrs['_type']).new(attrs)
179
+ rescue => e
180
+ log_error "Error loading type #{attrs['_type']}", e
181
+ nil
182
+ end
175
183
  end
184
+
185
+ events.compact!
176
186
  end
187
+
177
188
  result
178
189
  end
179
190
  end
@@ -1,3 +1,3 @@
1
1
  module EntityStore
2
- VERSION = "0.3.2".freeze
2
+ VERSION = "0.3.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bird
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo