mongoid-falsehoods 0.1.0 → 0.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -3
- data/lib/mongoid/falsehoods/monkeypatching.rb +24 -0
- data/lib/mongoid/falsehoods/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407464f6a1fbdf5874a6fc9fed4078e11e29c094033e7ec2fda24d38b922310d
|
4
|
+
data.tar.gz: 71334edf9c8b803565ecc0bfc8ab88800f17a906eee89fa6dc709a6a9b97fca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e333fa8d6d4e63629e1250a25dc5524b9ddf41e5b89a02df535e7043578d2ce4ae44f29116c377897ffc41098185105a5c723f093ef7775e2ae5b1675935b323
|
7
|
+
data.tar.gz: 9d2aef19db5fc5e6b2ff2a5dec11b700b34526f86575a4a4b48a4bfde92af642dcc6f3a784b398a26cf0ac533a73bbc90879b6da012932ef116f00a5a714ea7b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,12 +22,14 @@ Here's an example:
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
# before
|
25
|
-
User.where(deleted_at: nil).explain['executionStats']['executionTimeMillis'] #
|
25
|
+
User.where(deleted_at: nil).explain['executionStats']['executionTimeMillis'] # 4197
|
26
26
|
# after
|
27
|
-
User.where(deleted_at: false).explain['executionStats']['executionTimeMillis'] #=>
|
27
|
+
User.where(deleted_at: false).explain['executionStats']['executionTimeMillis'] #=> 3055
|
28
28
|
```
|
29
29
|
|
30
|
-
The improvement will vary based on the number of documents. That's with around
|
30
|
+
So by switching from `null` to `false`, we shaved off about a second from this query. The improvement will vary based on the number of documents. That's with around 790,000.
|
31
|
+
|
32
|
+
Hopefully Mongo will address [this Jira ticket](https://jira.mongodb.org/browse/SERVER-18861) at some point and make this gem unnecessary.
|
31
33
|
|
32
34
|
## Installation
|
33
35
|
|
@@ -29,4 +29,28 @@ module Mongoid
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
module Mongoid
|
33
|
+
module Extensions
|
34
|
+
module Time
|
35
|
+
module ClassMethods
|
36
|
+
alias_method :original_mongoize, :mongoize
|
37
|
+
alias_method :original_demongoize, :demongoize
|
38
|
+
|
39
|
+
def mongoize(object)
|
40
|
+
return false if object == false
|
41
|
+
|
42
|
+
original_mongoize(object)
|
43
|
+
end
|
44
|
+
|
45
|
+
def demongoize(object)
|
46
|
+
return false if object == false
|
47
|
+
|
48
|
+
original_demongoize(object)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
32
55
|
::DateTime.extend(Mongoid::Extensions::DateTime::ClassMethods)
|
56
|
+
::Time.extend(Mongoid::Extensions::Time::ClassMethods)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-falsehoods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|