bullet 5.0.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 +4 -4
- data/.travis.yml +44 -13
- data/CHANGELOG.md +14 -32
- data/Gemfile.mongoid-2.4 +0 -2
- data/Gemfile.mongoid-2.5 +0 -2
- data/Gemfile.mongoid-2.6 +0 -2
- data/Gemfile.mongoid-2.7 +0 -2
- data/Gemfile.mongoid-2.8 +0 -2
- data/Gemfile.mongoid-3.0 +0 -2
- data/Gemfile.mongoid-3.1 +0 -2
- data/Gemfile.mongoid-4.0 +0 -2
- data/Gemfile.mongoid-5.0 +1 -3
- data/Gemfile.rails-3.0 +1 -2
- data/Gemfile.rails-3.1 +1 -2
- data/Gemfile.rails-3.2 +1 -2
- data/Gemfile.rails-4.0 +1 -2
- data/Gemfile.rails-4.1 +1 -2
- data/Gemfile.rails-4.2 +1 -2
- data/Gemfile.rails-5.0 +1 -3
- data/Hacking.md +1 -0
- data/README.md +5 -4
- data/bullet.gemspec +1 -1
- data/lib/bullet/active_record3.rb +34 -4
- data/lib/bullet/active_record3x.rb +34 -4
- data/lib/bullet/active_record4.rb +24 -4
- data/lib/bullet/active_record41.rb +9 -1
- data/lib/bullet/active_record42.rb +13 -3
- data/lib/bullet/active_record5.rb +55 -54
- data/lib/bullet/detector/unused_eager_loading.rb +5 -7
- data/lib/bullet/notification/base.rb +2 -2
- data/lib/bullet/rack.rb +1 -1
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +8 -3
- data/spec/bullet/detector/unused_eager_loading_spec.rb +14 -2
- data/spec/bullet/rack_spec.rb +31 -0
- data/spec/bullet_spec.rb +9 -0
- data/spec/integration/active_record3/association_spec.rb +65 -1
- data/spec/integration/active_record4/association_spec.rb +56 -13
- data/spec/integration/active_record5/association_spec.rb +56 -13
- data/spec/spec_helper.rb +0 -3
- data/spec/support/sqlite_seed.rb +1 -0
- data/test.sh +1 -0
- data/update.sh +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbcef4cb1e9b0db722674cc600a456767eb5d2dd
|
|
4
|
+
data.tar.gz: 27107041da317defb0433329dc55375b305cc7b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea8208a3a4f1a1ef3f4f247667f9485b951a00ba5036cc87b8049005813e8f7452a5d340c1fdb09ea525fd5996b0050587a758afc8ff2a421f93acb21424f605
|
|
7
|
+
data.tar.gz: 456466364914301c30c4622bba947888bd16d92dad0603759c8b1108c4bc11ed417a8fca5a8ee2c983f119fa16e587cc140498393d2ec31f1a79c410082f1874
|
data/.travis.yml
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
sudo: false
|
|
2
2
|
language: ruby
|
|
3
3
|
rvm:
|
|
4
|
+
- 1.9.3
|
|
4
5
|
- 2.0
|
|
5
6
|
- 2.1
|
|
6
7
|
- 2.2
|
|
7
|
-
- 2.
|
|
8
|
+
- 2.3.0
|
|
8
9
|
gemfile:
|
|
9
10
|
- Gemfile.rails-5.0
|
|
10
11
|
- Gemfile.rails-4.2
|
|
@@ -28,11 +29,39 @@ services:
|
|
|
28
29
|
- mongodb
|
|
29
30
|
matrix:
|
|
30
31
|
exclude:
|
|
32
|
+
- rvm: 1.9.3
|
|
33
|
+
gemfile: Gemfile.rails-4.0
|
|
34
|
+
- rvm: 1.9.3
|
|
35
|
+
gemfile: Gemfile.rails-4.1
|
|
36
|
+
- rvm: 1.9.3
|
|
37
|
+
gemfile: Gemfile.rails-4.2
|
|
38
|
+
- rvm: 1.9.3
|
|
39
|
+
gemfile: Gemfile.rails-5.0
|
|
40
|
+
- rvm: 1.9.3
|
|
41
|
+
gemfile: Gemfile.mongoid-2.4
|
|
42
|
+
- rvm: 1.9.3
|
|
43
|
+
gemfile: Gemfile.mongoid-2.5
|
|
44
|
+
- rvm: 1.9.3
|
|
45
|
+
gemfile: Gemfile.mongoid-2.6
|
|
46
|
+
- rvm: 1.9.3
|
|
47
|
+
gemfile: Gemfile.mongoid-2.7
|
|
48
|
+
- rvm: 1.9.3
|
|
49
|
+
gemfile: Gemfile.mongoid-2.8
|
|
50
|
+
- rvm: 1.9.3
|
|
51
|
+
gemfile: Gemfile.mongoid-3.0
|
|
52
|
+
- rvm: 1.9.3
|
|
53
|
+
gemfile: Gemfile.mongoid-3.1
|
|
54
|
+
- rvm: 1.9.3
|
|
55
|
+
gemfile: Gemfile.mongoid-4.0
|
|
56
|
+
- rvm: 1.9.3
|
|
57
|
+
gemfile: Gemfile.mongoid-5.0
|
|
58
|
+
- rvm: 2.0
|
|
59
|
+
gemfile: Gemfile.rails-3.0
|
|
31
60
|
- rvm: 2.0
|
|
32
61
|
gemfile: Gemfile.rails-5.0
|
|
33
62
|
- rvm: 2.1
|
|
34
|
-
gemfile: Gemfile.rails-
|
|
35
|
-
- rvm: 2.
|
|
63
|
+
gemfile: Gemfile.rails-3.0
|
|
64
|
+
- rvm: 2.1
|
|
36
65
|
gemfile: Gemfile.rails-5.0
|
|
37
66
|
- rvm: 2.2
|
|
38
67
|
gemfile: Gemfile.rails-3.0
|
|
@@ -40,6 +69,8 @@ matrix:
|
|
|
40
69
|
gemfile: Gemfile.rails-3.1
|
|
41
70
|
- rvm: 2.2
|
|
42
71
|
gemfile: Gemfile.rails-3.2
|
|
72
|
+
- rvm: 2.2
|
|
73
|
+
gemfile: Gemfile.rails-5.0
|
|
43
74
|
- rvm: 2.2
|
|
44
75
|
gemfile: Gemfile.mongoid-3.1
|
|
45
76
|
- rvm: 2.2
|
|
@@ -54,23 +85,23 @@ matrix:
|
|
|
54
85
|
gemfile: Gemfile.mongoid-2.5
|
|
55
86
|
- rvm: 2.2
|
|
56
87
|
gemfile: Gemfile.mongoid-2.4
|
|
57
|
-
- rvm: 2.
|
|
88
|
+
- rvm: 2.3.0
|
|
58
89
|
gemfile: Gemfile.rails-3.0
|
|
59
|
-
- rvm: 2.
|
|
90
|
+
- rvm: 2.3.0
|
|
60
91
|
gemfile: Gemfile.rails-3.1
|
|
61
|
-
- rvm: 2.
|
|
92
|
+
- rvm: 2.3.0
|
|
62
93
|
gemfile: Gemfile.rails-3.2
|
|
63
|
-
- rvm: 2.
|
|
94
|
+
- rvm: 2.3.0
|
|
64
95
|
gemfile: Gemfile.mongoid-3.1
|
|
65
|
-
- rvm: 2.
|
|
96
|
+
- rvm: 2.3.0
|
|
66
97
|
gemfile: Gemfile.mongoid-3.0
|
|
67
|
-
- rvm: 2.
|
|
98
|
+
- rvm: 2.3.0
|
|
68
99
|
gemfile: Gemfile.mongoid-2.8
|
|
69
|
-
- rvm: 2.
|
|
100
|
+
- rvm: 2.3.0
|
|
70
101
|
gemfile: Gemfile.mongoid-2.7
|
|
71
|
-
- rvm: 2.
|
|
102
|
+
- rvm: 2.3.0
|
|
72
103
|
gemfile: Gemfile.mongoid-2.6
|
|
73
|
-
- rvm: 2.
|
|
104
|
+
- rvm: 2.3.0
|
|
74
105
|
gemfile: Gemfile.mongoid-2.5
|
|
75
|
-
- rvm: 2.
|
|
106
|
+
- rvm: 2.3.0
|
|
76
107
|
gemfile: Gemfile.mongoid-2.4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
# Next Release
|
|
2
2
|
|
|
3
|
-
## 5.
|
|
3
|
+
## 5.2.0 (07/26/2016)
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* Fix `has_cached_counter?` is not defined in HABTM #297
|
|
6
|
+
* Fix false alert if preloaded association has no records #260
|
|
7
|
+
* Support Rails 5.0.0
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## 5.1.0 (05/21/2016)
|
|
8
10
|
|
|
9
|
-
* Fix
|
|
11
|
+
* Fix false alert when `empty?` used with `counter_cache`
|
|
12
|
+
* Fix `alias_method_chain` deprecation for rails 5
|
|
13
|
+
* Add response handling for non-Rails Rack responses
|
|
14
|
+
* Fix false alert when querying immediately after creation
|
|
15
|
+
* Fix UnusedEagerLoading bug when multiple eager loading query include same objects
|
|
10
16
|
|
|
11
|
-
##
|
|
17
|
+
## 5.0.0 (01/06/2016)
|
|
12
18
|
|
|
19
|
+
* Support Rails 5.0.0.beta1
|
|
20
|
+
* Fix `has_many :through` infinite loop issue
|
|
13
21
|
* Support mongoid 5.0.0
|
|
14
22
|
* Do not report association queries immediately after object creation to
|
|
15
23
|
require a preload
|
|
16
24
|
* Detect `counter_cache` for `has_many :through` association
|
|
17
|
-
|
|
18
|
-
## 4.14.8
|
|
19
|
-
|
|
20
|
-
* compatible with `composite_primary_keys` gem
|
|
21
|
-
|
|
22
|
-
## 4.14.7
|
|
23
|
-
|
|
25
|
+
* Compatible with `composite_primary_keys` gem
|
|
24
26
|
* Fix AR 4.2 SingularAssociation#reader result can be nil
|
|
25
27
|
* `perform_out_of_channel_notifications` should always be triggered
|
|
26
|
-
|
|
27
|
-
## 4.14.6
|
|
28
|
-
|
|
29
28
|
* Fix false positive with `belongs_to` -> `belongs_to` for active\_record 4.2
|
|
30
29
|
* Activate active\_record hacks only when Bullet already start
|
|
31
|
-
|
|
32
|
-
## 4.14.5
|
|
33
|
-
|
|
34
30
|
* Don't execute query when running `to_sql`
|
|
35
31
|
* Send backtrace to `uniform_notifier`
|
|
36
32
|
* Fix sse response check
|
|
37
33
|
* Dynamically delegate available notifiers to UniformNotifier
|
|
38
|
-
|
|
39
|
-
## 4.14.4
|
|
40
|
-
|
|
41
|
-
* Fix false N + 1 warnings on Rails 4.2
|
|
42
|
-
|
|
43
|
-
## 4.14.3
|
|
44
|
-
|
|
45
|
-
* Fix false positive on create
|
|
46
|
-
|
|
47
|
-
## 4.14.2
|
|
48
|
-
|
|
49
34
|
* Hotfix nil object when `add_impossible_object`
|
|
50
|
-
|
|
51
|
-
## 4.14.1
|
|
52
|
-
|
|
53
35
|
* Fix `has_one` then `has_many` associations in rails 4.2
|
|
54
36
|
* Append js and dom to html body in proper position
|
|
55
37
|
|
data/Gemfile.mongoid-2.4
CHANGED
data/Gemfile.mongoid-2.5
CHANGED
data/Gemfile.mongoid-2.6
CHANGED
data/Gemfile.mongoid-2.7
CHANGED
data/Gemfile.mongoid-2.8
CHANGED
data/Gemfile.mongoid-3.0
CHANGED
data/Gemfile.mongoid-3.1
CHANGED
data/Gemfile.mongoid-4.0
CHANGED
data/Gemfile.mongoid-5.0
CHANGED
|
@@ -5,12 +5,10 @@ gemspec
|
|
|
5
5
|
gem 'rails', '~> 4.0.0'
|
|
6
6
|
gem 'sqlite3', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
|
-
gem 'mongoid', '~> 5.0.0
|
|
8
|
+
gem 'mongoid', '~> 5.0.0'
|
|
9
9
|
|
|
10
10
|
gem "rspec"
|
|
11
11
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
12
|
platforms :rbx do
|
|
15
13
|
gem 'rubysl', '~> 2.0'
|
|
16
14
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-3.0
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 3.0.0'
|
|
|
6
6
|
gem 'sqlite3', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-3.1
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 3.1.0'
|
|
|
6
6
|
gem 'sqlite3', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-3.2
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 3.2.0'
|
|
|
6
6
|
gem 'sqlite3', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-4.0
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 4.0.0'
|
|
|
6
6
|
gem 'sqlite3', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-4.1
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 4.1.0'
|
|
|
6
6
|
gem 'sqlite3'
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-4.2
CHANGED
|
@@ -6,11 +6,10 @@ gem 'rails', '~> 4.2.0'
|
|
|
6
6
|
gem 'sqlite3'
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
|
+
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
|
9
10
|
|
|
10
11
|
gem "rspec"
|
|
11
12
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
13
|
platforms :rbx do
|
|
15
14
|
gem 'rubysl', '~> 2.0'
|
|
16
15
|
gem 'rubinius-developer_tools'
|
data/Gemfile.rails-5.0
CHANGED
|
@@ -2,15 +2,13 @@ source "https://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
gem 'rails', '5.0.0
|
|
5
|
+
gem 'rails', '5.0.0'
|
|
6
6
|
gem 'sqlite3'
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
9
|
|
|
10
10
|
gem "rspec"
|
|
11
11
|
|
|
12
|
-
gem 'coveralls', require: false
|
|
13
|
-
|
|
14
12
|
platforms :rbx do
|
|
15
13
|
gem 'rubysl', '~> 2.0'
|
|
16
14
|
gem 'rubinius-developer_tools'
|
data/Hacking.md
CHANGED
|
@@ -23,6 +23,7 @@ Notification instances contain the message that will be displayed, and will
|
|
|
23
23
|
use a Presenter class to display their message to the user.
|
|
24
24
|
|
|
25
25
|
So the flow of a request goes like this:
|
|
26
|
+
|
|
26
27
|
1. Bullet.start_request is called, which resets all the detectors and empties
|
|
27
28
|
the notification collector
|
|
28
29
|
2. The request is handled by Rails, and the installed ActiveRecord extensions
|
data/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/bullet)
|
|
4
4
|
[](http://travis-ci.org/flyerhzm/bullet)
|
|
5
|
-
[](https://coveralls.io/r/flyerhzm/bullet)
|
|
6
5
|
<a href="https://codeclimate.com/github/flyerhzm/bullet"><img src="https://codeclimate.com/github/flyerhzm/bullet.png" /></a>
|
|
7
6
|
[](http://coderwall.com/flyerhzm)
|
|
8
7
|
|
|
@@ -63,7 +62,7 @@ config.after_initialize do
|
|
|
63
62
|
Bullet.add_footer = true
|
|
64
63
|
Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]
|
|
65
64
|
Bullet.stacktrace_excludes = [ 'their_gem', 'their_middleware' ]
|
|
66
|
-
Bullet.slack = { webhook_url: 'http://some.slack.url',
|
|
65
|
+
Bullet.slack = { webhook_url: 'http://some.slack.url', channel: '#default', username: 'notifier' }
|
|
67
66
|
end
|
|
68
67
|
```
|
|
69
68
|
|
|
@@ -238,7 +237,9 @@ Bullet outputs some details info, to enable debug mode, set
|
|
|
238
237
|
|
|
239
238
|
## Demo
|
|
240
239
|
|
|
241
|
-
Bullet is designed to function as you browse through your application in development. To see it in action,
|
|
240
|
+
Bullet is designed to function as you browse through your application in development. To see it in action,
|
|
241
|
+
you can visit [https://github.com/flyerhzm/bullet_test](https://github.com/flyerhzm/bullet_test) or
|
|
242
|
+
follow these steps to create, detect, and fix example query problems.
|
|
242
243
|
|
|
243
244
|
1\. Create an example application
|
|
244
245
|
|
|
@@ -458,4 +459,4 @@ Meanwhile, there's a line appended to `log/bullet.log`
|
|
|
458
459
|
Post => [:comments]
|
|
459
460
|
```
|
|
460
461
|
|
|
461
|
-
Copyright (c) 2009 -
|
|
462
|
+
Copyright (c) 2009 - 2016 Richard Huang (flyerhzm@gmail.com), released under the MIT license
|
data/bullet.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.required_rubygems_version = ">= 1.3.6"
|
|
19
19
|
|
|
20
20
|
s.add_runtime_dependency "activesupport", ">= 3.0.0"
|
|
21
|
-
s.add_runtime_dependency "uniform_notifier", "~> 1.
|
|
21
|
+
s.add_runtime_dependency "uniform_notifier", "~> 1.10.0"
|
|
22
22
|
|
|
23
23
|
s.files = `git ls-files`.split("\n")
|
|
24
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
@@ -23,6 +23,24 @@ module Bullet
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
::ActiveRecord::Persistence.class_eval do
|
|
27
|
+
alias_method :origin_save, :save
|
|
28
|
+
def save(*args, &proc)
|
|
29
|
+
was_new_record = new_record?
|
|
30
|
+
origin_save(*args, &proc).tap do |result|
|
|
31
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
alias_method :origin_save!, :save!
|
|
36
|
+
def save!(*args, &proc)
|
|
37
|
+
was_new_record = new_record?
|
|
38
|
+
origin_save!(*args, &proc).tap do |result|
|
|
39
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
26
44
|
::ActiveRecord::AssociationPreload::ClassMethods.class_eval do
|
|
27
45
|
alias_method :origin_preload_associations, :preload_associations
|
|
28
46
|
# include query for one to many associations.
|
|
@@ -116,20 +134,32 @@ module Bullet
|
|
|
116
134
|
origin_last(*args)
|
|
117
135
|
end
|
|
118
136
|
|
|
137
|
+
alias_method :origin_include?, :include?
|
|
138
|
+
def include?(object)
|
|
139
|
+
if Bullet.start?
|
|
140
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
141
|
+
end
|
|
142
|
+
origin_include?(object)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
::ActiveRecord::Associations::HasManyAssociation.class_eval do
|
|
119
147
|
alias_method :origin_empty?, :empty?
|
|
120
148
|
def empty?
|
|
121
|
-
if Bullet.start?
|
|
149
|
+
if Bullet.start? && !has_cached_counter?
|
|
122
150
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
123
151
|
end
|
|
124
152
|
origin_empty?
|
|
125
153
|
end
|
|
154
|
+
end
|
|
126
155
|
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
::ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do
|
|
157
|
+
alias_method :origin_empty?, :empty?
|
|
158
|
+
def empty?
|
|
129
159
|
if Bullet.start?
|
|
130
160
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
131
161
|
end
|
|
132
|
-
|
|
162
|
+
origin_empty?
|
|
133
163
|
end
|
|
134
164
|
end
|
|
135
165
|
|
|
@@ -21,6 +21,24 @@ module Bullet
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
::ActiveRecord::Persistence.class_eval do
|
|
25
|
+
alias_method :origin_save, :save
|
|
26
|
+
def save(*args, &proc)
|
|
27
|
+
was_new_record = new_record?
|
|
28
|
+
origin_save(*args, &proc).tap do |result|
|
|
29
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
alias_method :origin_save!, :save!
|
|
34
|
+
def save!(*args, &proc)
|
|
35
|
+
was_new_record = new_record?
|
|
36
|
+
origin_save!(*args, &proc).tap do |result|
|
|
37
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
24
42
|
::ActiveRecord::Associations::Preloader.class_eval do
|
|
25
43
|
# include query for one to many associations.
|
|
26
44
|
# keep this eager loadings.
|
|
@@ -98,20 +116,32 @@ module Bullet
|
|
|
98
116
|
origin_load_target
|
|
99
117
|
end
|
|
100
118
|
|
|
119
|
+
alias_method :origin_include?, :include?
|
|
120
|
+
def include?(object)
|
|
121
|
+
if Bullet.start?
|
|
122
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
123
|
+
end
|
|
124
|
+
origin_include?(object)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
::ActiveRecord::Associations::HasManyAssociation.class_eval do
|
|
101
129
|
alias_method :origin_empty?, :empty?
|
|
102
130
|
def empty?
|
|
103
|
-
if Bullet.start?
|
|
131
|
+
if Bullet.start? && !has_cached_counter?(@reflection)
|
|
104
132
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
105
133
|
end
|
|
106
134
|
origin_empty?
|
|
107
135
|
end
|
|
136
|
+
end
|
|
108
137
|
|
|
109
|
-
|
|
110
|
-
|
|
138
|
+
::ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do
|
|
139
|
+
alias_method :origin_empty?, :empty?
|
|
140
|
+
def empty?
|
|
111
141
|
if Bullet.start?
|
|
112
142
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
113
143
|
end
|
|
114
|
-
|
|
144
|
+
origin_empty?
|
|
115
145
|
end
|
|
116
146
|
end
|
|
117
147
|
|
|
@@ -29,6 +29,14 @@ module Bullet
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
alias_method_chain :save, :bullet
|
|
32
|
+
|
|
33
|
+
def save_with_bullet!(*args, &proc)
|
|
34
|
+
was_new_record = new_record?
|
|
35
|
+
save_without_bullet!(*args, &proc).tap do |result|
|
|
36
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
alias_method_chain :save!, :bullet
|
|
32
40
|
end
|
|
33
41
|
|
|
34
42
|
::ActiveRecord::Associations::Preloader.class_eval do
|
|
@@ -108,20 +116,32 @@ module Bullet
|
|
|
108
116
|
origin_load_target
|
|
109
117
|
end
|
|
110
118
|
|
|
119
|
+
alias_method :origin_include?, :include?
|
|
120
|
+
def include?(object)
|
|
121
|
+
if Bullet.start?
|
|
122
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
123
|
+
end
|
|
124
|
+
origin_include?(object)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
::ActiveRecord::Associations::HasManyAssociation.class_eval do
|
|
111
129
|
alias_method :origin_empty?, :empty?
|
|
112
130
|
def empty?
|
|
113
|
-
if Bullet.start?
|
|
131
|
+
if Bullet.start? && !has_cached_counter?(@reflection)
|
|
114
132
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
115
133
|
end
|
|
116
134
|
origin_empty?
|
|
117
135
|
end
|
|
136
|
+
end
|
|
118
137
|
|
|
119
|
-
|
|
120
|
-
|
|
138
|
+
::ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do
|
|
139
|
+
alias_method :origin_empty?, :empty?
|
|
140
|
+
def empty?
|
|
121
141
|
if Bullet.start?
|
|
122
142
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
123
143
|
end
|
|
124
|
-
|
|
144
|
+
origin_empty?
|
|
125
145
|
end
|
|
126
146
|
end
|
|
127
147
|
|
|
@@ -31,6 +31,14 @@ module Bullet
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
alias_method_chain :save, :bullet
|
|
34
|
+
|
|
35
|
+
def save_with_bullet!(*args, &proc)
|
|
36
|
+
was_new_record = new_record?
|
|
37
|
+
save_without_bullet!(*args, &proc).tap do |result|
|
|
38
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
alias_method_chain :save!, :bullet
|
|
34
42
|
end
|
|
35
43
|
|
|
36
44
|
::ActiveRecord::Associations::Preloader.class_eval do
|
|
@@ -113,7 +121,7 @@ module Bullet
|
|
|
113
121
|
|
|
114
122
|
alias_method :origin_empty?, :empty?
|
|
115
123
|
def empty?
|
|
116
|
-
if Bullet.start?
|
|
124
|
+
if Bullet.start? && !has_cached_counter?(@reflection)
|
|
117
125
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
118
126
|
end
|
|
119
127
|
origin_empty?
|