bullet 5.7.5 → 6.0.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 +5 -5
- data/.travis.yml +2 -0
- data/CHANGELOG.md +17 -14
- data/Gemfile.mongoid-7.0 +15 -0
- data/Gemfile.rails-4.0 +1 -1
- data/Gemfile.rails-4.1 +1 -1
- data/Gemfile.rails-4.2 +1 -1
- data/Gemfile.rails-5.0 +1 -1
- data/Gemfile.rails-5.1 +1 -1
- data/Gemfile.rails-5.2 +2 -2
- data/Gemfile.rails-6.0 +15 -0
- data/README.md +8 -5
- data/Rakefile +1 -1
- data/bullet.gemspec +8 -3
- data/lib/bullet/active_record4.rb +5 -13
- data/lib/bullet/active_record41.rb +5 -13
- data/lib/bullet/active_record42.rb +6 -13
- data/lib/bullet/active_record5.rb +15 -13
- data/lib/bullet/active_record52.rb +12 -13
- data/lib/bullet/active_record60.rb +245 -0
- data/lib/bullet/bullet_xhr.js +58 -0
- data/lib/bullet/dependency.rb +17 -5
- data/lib/bullet/detector/association.rb +4 -4
- data/lib/bullet/detector/counter_cache.rb +4 -3
- data/lib/bullet/detector/n_plus_one_query.rb +13 -13
- data/lib/bullet/detector/unused_eager_loading.rb +2 -1
- data/lib/bullet/ext/object.rb +5 -3
- data/lib/bullet/ext/string.rb +1 -1
- data/lib/bullet/mongoid4x.rb +1 -0
- data/lib/bullet/mongoid5x.rb +1 -0
- data/lib/bullet/mongoid6x.rb +5 -4
- data/lib/bullet/mongoid7x.rb +61 -0
- data/lib/bullet/notification/base.rb +1 -1
- data/lib/bullet/rack.rb +45 -27
- data/lib/bullet/stack_trace_filter.rb +43 -25
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +21 -5
- data/lib/generators/bullet/install_generator.rb +3 -3
- data/spec/bullet/detector/n_plus_one_query_spec.rb +23 -0
- data/spec/bullet/ext/object_spec.rb +9 -4
- data/spec/bullet/rack_spec.rb +12 -3
- data/spec/integration/active_record/association_spec.rb +52 -3
- data/spec/integration/counter_cache_spec.rb +1 -1
- data/spec/models/client.rb +2 -0
- data/spec/models/firm.rb +1 -0
- data/spec/models/group.rb +4 -0
- data/spec/models/post.rb +15 -0
- data/spec/support/sqlite_seed.rb +9 -2
- data/test.sh +2 -0
- data/update.sh +1 -0
- metadata +16 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 749d1d92dc0373b1f2521c85825dfea656e985c438cdfafe774242b31f25c2d5
|
|
4
|
+
data.tar.gz: 4e76a9da65613f2b9cf3802f4969f84c1e5bb9849c5892898fa9d999fde3900c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72f8f18edecb79d8631a215229afb71bb94050c0fcc65794a88dc3adf21545acf4ae38eb59bd6bdfa0e34609854ab149d02f47e761fba00452e28f2575306376
|
|
7
|
+
data.tar.gz: 94058fcb502d63ce470b6dfa06d05dd367c8a7e251948040b91c22164d6583d8a82ab120bb2a42d109c121170042573c9964aaa55ebc0093c07adc1fb8f23fd5
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
## Next Release
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 6.0.0 (02/22/2019)
|
|
4
4
|
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Add XHR support to Bullet
|
|
6
|
+
* Support Rails 6.0
|
|
7
|
+
* Handle case where ID is manually set on unpersisted record
|
|
7
8
|
|
|
8
|
-
## 5.
|
|
9
|
+
## 5.9.0 (11/11/2018)
|
|
9
10
|
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* Require Ruby 2.3+
|
|
12
|
+
* Support Mongo 7.x
|
|
12
13
|
|
|
13
|
-
## 5.
|
|
14
|
+
## 5.8.0 (10/29/2018)
|
|
14
15
|
|
|
16
|
+
* Fix through reflection for rails 5.x
|
|
17
|
+
* Fix false positive in after_save/after_create callbacks
|
|
18
|
+
* Don't triger a preload error on "manual" preloads
|
|
19
|
+
* Avoid Bullet from making extra queries in mongoid6
|
|
20
|
+
* Support option for #first and #last on mongoid6.x
|
|
21
|
+
* Fix duplicate logs in mongoid 4.x and 5.x version
|
|
22
|
+
* Use caller for ruby 1.9 while caller_locations for 2.0+
|
|
23
|
+
* Extend stacktrace matching for sub-file precision
|
|
15
24
|
* Exclude configured bundler path in addition to '/vendor'
|
|
16
|
-
* Support rails 5.1.5
|
|
17
|
-
|
|
18
|
-
## 5.7.2 (18/01/2018)
|
|
19
|
-
|
|
20
25
|
* Fix `caller_path` in `excluded_stacktrace_path`
|
|
21
|
-
|
|
22
|
-
## 5.7.1 (07/01/2017)
|
|
23
|
-
|
|
24
26
|
* Update `uniform_notifier` dependency to add Sentry support
|
|
27
|
+
* Integrate awesomecode.io and refactor code
|
|
25
28
|
|
|
26
29
|
## 5.7.0 (12/03/2017)
|
|
27
30
|
|
data/Gemfile.mongoid-7.0
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
gem 'rails', '~> 5.0'
|
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
|
+
gem 'mongoid', '~> 7.0.0'
|
|
9
|
+
|
|
10
|
+
gem "rspec"
|
|
11
|
+
|
|
12
|
+
platforms :rbx do
|
|
13
|
+
gem 'rubysl', '~> 2.0'
|
|
14
|
+
gem 'rubinius-developer_tools'
|
|
15
|
+
end
|
data/Gemfile.rails-4.0
CHANGED
|
@@ -3,7 +3,7 @@ source "https://rubygems.org"
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
5
|
gem 'rails', '~> 4.0.0'
|
|
6
|
-
gem 'sqlite3', platforms: [:ruby]
|
|
6
|
+
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby]
|
|
7
7
|
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
8
|
gem 'activerecord-import'
|
|
9
9
|
gem 'tins', '~> 1.6.0', platforms: [:ruby_19]
|
data/Gemfile.rails-4.1
CHANGED
data/Gemfile.rails-4.2
CHANGED
data/Gemfile.rails-5.0
CHANGED
data/Gemfile.rails-5.1
CHANGED
data/Gemfile.rails-5.2
CHANGED
data/Gemfile.rails-6.0
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
gem 'rails', '6.0.0.rc1'
|
|
6
|
+
gem 'sqlite3'
|
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
|
8
|
+
gem 'activerecord-import'
|
|
9
|
+
|
|
10
|
+
gem "rspec"
|
|
11
|
+
|
|
12
|
+
platforms :rbx do
|
|
13
|
+
gem 'rubysl', '~> 2.0'
|
|
14
|
+
gem 'rubinius-developer_tools'
|
|
15
|
+
end
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/bullet)
|
|
4
4
|
[](http://travis-ci.org/flyerhzm/bullet)
|
|
5
|
-
[](https://awesomecode.io/
|
|
5
|
+
[](https://awesomecode.io/repos/flyerhzm/bullet)
|
|
6
6
|
[](http://coderwall.com/flyerhzm)
|
|
7
7
|
|
|
8
8
|
The Bullet gem is designed to help you increase your application's performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries), when you're using eager loading that isn't necessary and when you should use counter cache.
|
|
@@ -64,7 +64,7 @@ config.after_initialize do
|
|
|
64
64
|
Bullet.rollbar = true
|
|
65
65
|
Bullet.add_footer = true
|
|
66
66
|
Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]
|
|
67
|
-
Bullet.stacktrace_excludes = [ 'their_gem', 'their_middleware' ]
|
|
67
|
+
Bullet.stacktrace_excludes = [ 'their_gem', 'their_middleware', ['my_file.rb', 'my_method'], ['my_file.rb', 16..20] ]
|
|
68
68
|
Bullet.slack = { webhook_url: 'http://some.slack.url', channel: '#default', username: 'notifier' }
|
|
69
69
|
end
|
|
70
70
|
```
|
|
@@ -87,6 +87,8 @@ The code above will enable all of the Bullet notification systems:
|
|
|
87
87
|
* `Bullet.add_footer`: adds the details in the bottom left corner of the page. Double click the footer or use close button to hide footer.
|
|
88
88
|
* `Bullet.stacktrace_includes`: include paths with any of these substrings in the stack trace, even if they are not in your main app
|
|
89
89
|
* `Bullet.stacktrace_excludes`: ignore paths with any of these substrings in the stack trace, even if they are not in your main app.
|
|
90
|
+
Each item can be a string (match substring), a regex, or an array where the first item is a path to match, and the second
|
|
91
|
+
item is a line number, a Range of line numbers, or a (bare) method name, to exclude only particular lines in a file.
|
|
90
92
|
* `Bullet.slack`: add notifications to slack
|
|
91
93
|
* `Bullet.raise`: raise errors, useful for making your specs fail unless they have optimized queries
|
|
92
94
|
|
|
@@ -126,10 +128,11 @@ class ApplicationController < ActionController::Base
|
|
|
126
128
|
around_action :skip_bullet
|
|
127
129
|
|
|
128
130
|
def skip_bullet
|
|
131
|
+
previous_value = Bullet.enable?
|
|
129
132
|
Bullet.enable = false
|
|
130
133
|
yield
|
|
131
134
|
ensure
|
|
132
|
-
Bullet.enable =
|
|
135
|
+
Bullet.enable = previous_value
|
|
133
136
|
end
|
|
134
137
|
end
|
|
135
138
|
```
|
|
@@ -180,7 +183,7 @@ If you find Bullet does not work for you, *please disable your browser's cache*.
|
|
|
180
183
|
|
|
181
184
|
### Profile a job
|
|
182
185
|
|
|
183
|
-
The Bullet gem uses rack middleware to profile requests. If you want to use Bullet without an http server, like to profile a job, you can use
|
|
186
|
+
The Bullet gem uses rack middleware to profile requests. If you want to use Bullet without an http server, like to profile a job, you can use the profile method and fetch warnings
|
|
184
187
|
|
|
185
188
|
```ruby
|
|
186
189
|
Bullet.profile do
|
|
@@ -218,7 +221,7 @@ end
|
|
|
218
221
|
Then wrap each test in Bullet api.
|
|
219
222
|
|
|
220
223
|
```ruby
|
|
221
|
-
# spec/
|
|
224
|
+
# spec/rails_helper.rb
|
|
222
225
|
if Bullet.enable?
|
|
223
226
|
config.before(:each) do
|
|
224
227
|
Bullet.start_request
|
data/Rakefile
CHANGED
data/bullet.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path('
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
|
6
6
|
require 'bullet/version'
|
|
@@ -14,13 +14,18 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
s.homepage = 'https://github.com/flyerhzm/bullet'
|
|
15
15
|
s.summary = 'help to kill N+1 queries and unused eager loading.'
|
|
16
16
|
s.description = 'help to kill N+1 queries and unused eager loading.'
|
|
17
|
+
s.metadata = {
|
|
18
|
+
'changelog_uri' => 'https://github.com/flyerhzm/bullet/blob/master/CHANGELOG.md',
|
|
19
|
+
'source_code_uri' => 'https://github.com/flyerhzm/bullet'
|
|
20
|
+
}
|
|
17
21
|
|
|
18
|
-
s.license
|
|
22
|
+
s.license = 'MIT'
|
|
19
23
|
|
|
24
|
+
s.required_ruby_version = '>= 2.3'
|
|
20
25
|
s.required_rubygems_version = '>= 1.3.6'
|
|
21
26
|
|
|
22
27
|
s.add_runtime_dependency 'activesupport', '>= 3.0.0'
|
|
23
|
-
s.add_runtime_dependency 'uniform_notifier', '~> 1.11
|
|
28
|
+
s.add_runtime_dependency 'uniform_notifier', '~> 1.11'
|
|
24
29
|
|
|
25
30
|
s.files = `git ls-files`.split("\n")
|
|
26
31
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
@@ -48,21 +48,12 @@ module Bullet
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
::ActiveRecord::Persistence.class_eval do
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
51
|
+
def _create_record_with_bullet(*args)
|
|
52
|
+
_create_record_without_bullet(*args).tap do
|
|
53
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
|
-
alias_method_chain :
|
|
58
|
-
|
|
59
|
-
def save_with_bullet!(*args, &proc)
|
|
60
|
-
was_new_record = new_record?
|
|
61
|
-
save_without_bullet!(*args, &proc).tap do |result|
|
|
62
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
alias_method_chain :save!, :bullet
|
|
56
|
+
alias_method_chain :_create_record, :bullet
|
|
66
57
|
end
|
|
67
58
|
|
|
68
59
|
::ActiveRecord::Associations::Preloader.class_eval do
|
|
@@ -74,6 +65,7 @@ module Bullet
|
|
|
74
65
|
if Bullet.start?
|
|
75
66
|
records = [records].flatten.compact.uniq
|
|
76
67
|
return if records.empty?
|
|
68
|
+
|
|
77
69
|
records.each do |record|
|
|
78
70
|
Bullet::Detector::Association.add_object_associations(record, associations)
|
|
79
71
|
end
|
|
@@ -50,21 +50,12 @@ module Bullet
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
::ActiveRecord::Persistence.class_eval do
|
|
53
|
-
def
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
53
|
+
def _create_record_with_bullet(*args)
|
|
54
|
+
_create_record_without_bullet(*args).tap do
|
|
55
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
|
-
alias_method_chain :
|
|
60
|
-
|
|
61
|
-
def save_with_bullet!(*args, &proc)
|
|
62
|
-
was_new_record = new_record?
|
|
63
|
-
save_without_bullet!(*args, &proc).tap do |result|
|
|
64
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
alias_method_chain :save!, :bullet
|
|
58
|
+
alias_method_chain :_create_record, :bullet
|
|
68
59
|
end
|
|
69
60
|
|
|
70
61
|
::ActiveRecord::Associations::Preloader.class_eval do
|
|
@@ -89,6 +80,7 @@ module Bullet
|
|
|
89
80
|
alias_method :origin_find_with_associations, :find_with_associations
|
|
90
81
|
def find_with_associations
|
|
91
82
|
return origin_find_with_associations { |r| yield r } if block_given?
|
|
83
|
+
|
|
92
84
|
records = origin_find_with_associations
|
|
93
85
|
if Bullet.start?
|
|
94
86
|
associations = (eager_load_values + includes_values).uniq
|
|
@@ -44,21 +44,12 @@ module Bullet
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
::ActiveRecord::Persistence.class_eval do
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
47
|
+
def _create_record_with_bullet(*args)
|
|
48
|
+
_create_record_without_bullet(*args).tap do
|
|
49
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
|
|
51
50
|
end
|
|
52
51
|
end
|
|
53
|
-
alias_method_chain :
|
|
54
|
-
|
|
55
|
-
def save_with_bullet!(*args, &proc)
|
|
56
|
-
was_new_record = new_record?
|
|
57
|
-
save_without_bullet!(*args, &proc).tap do |result|
|
|
58
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
alias_method_chain :save!, :bullet
|
|
52
|
+
alias_method_chain :_create_record, :bullet
|
|
62
53
|
end
|
|
63
54
|
|
|
64
55
|
::ActiveRecord::Relation.class_eval do
|
|
@@ -104,6 +95,7 @@ module Bullet
|
|
|
104
95
|
alias_method :origin_find_with_associations, :find_with_associations
|
|
105
96
|
def find_with_associations
|
|
106
97
|
return origin_find_with_associations { |r| yield r } if block_given?
|
|
98
|
+
|
|
107
99
|
records = origin_find_with_associations
|
|
108
100
|
if Bullet.start?
|
|
109
101
|
associations = (eager_load_values + includes_values).uniq
|
|
@@ -141,6 +133,7 @@ module Bullet
|
|
|
141
133
|
key = aliases.column_alias(node, node.primary_key)
|
|
142
134
|
id = row[key]
|
|
143
135
|
next unless id.nil?
|
|
136
|
+
|
|
144
137
|
associations = node.reflection.name
|
|
145
138
|
Bullet::Detector::Association.add_object_associations(ar_parent, associations)
|
|
146
139
|
Bullet::Detector::NPlusOneQuery.call_association(ar_parent, associations)
|
|
@@ -2,17 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Bullet
|
|
4
4
|
module SaveWithBulletSupport
|
|
5
|
-
def
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def save!(*args)
|
|
13
|
-
was_new_record = new_record?
|
|
14
|
-
super(*args).tap do |result|
|
|
15
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
5
|
+
def _create_record(*)
|
|
6
|
+
super do
|
|
7
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
|
|
8
|
+
yield(self) if block_given?
|
|
16
9
|
end
|
|
17
10
|
end
|
|
18
11
|
end
|
|
@@ -82,6 +75,7 @@ module Bullet
|
|
|
82
75
|
# add includes in scope
|
|
83
76
|
def find_with_associations
|
|
84
77
|
return super { |r| yield r } if block_given?
|
|
78
|
+
|
|
85
79
|
records = super
|
|
86
80
|
if Bullet.start?
|
|
87
81
|
associations = (eager_load_values + includes_values).uniq
|
|
@@ -132,6 +126,7 @@ module Bullet
|
|
|
132
126
|
key = aliases.column_alias(node, node.primary_key)
|
|
133
127
|
id = row[key]
|
|
134
128
|
next unless id.nil?
|
|
129
|
+
|
|
135
130
|
associations = node.reflection.name
|
|
136
131
|
Bullet::Detector::Association.add_object_associations(ar_parent, associations)
|
|
137
132
|
Bullet::Detector::NPlusOneQuery.call_association(ar_parent, associations)
|
|
@@ -168,11 +163,18 @@ module Bullet
|
|
|
168
163
|
|
|
169
164
|
if Bullet.start?
|
|
170
165
|
if is_a? ::ActiveRecord::Associations::ThroughAssociation
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
refl = reflection.through_reflection
|
|
167
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, refl.name)
|
|
168
|
+
association = owner.association refl.name
|
|
173
169
|
Array(association.target).each do |through_record|
|
|
174
170
|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
|
|
175
171
|
end
|
|
172
|
+
|
|
173
|
+
if refl.through_reflection?
|
|
174
|
+
refl = refl.through_reflection while refl.through_reflection?
|
|
175
|
+
|
|
176
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, refl.name)
|
|
177
|
+
end
|
|
176
178
|
end
|
|
177
179
|
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
|
|
178
180
|
if records.first.class.name !~ /^HABTM_/
|
|
@@ -2,17 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Bullet
|
|
4
4
|
module SaveWithBulletSupport
|
|
5
|
-
def
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def save!(*args)
|
|
13
|
-
was_new_record = new_record?
|
|
14
|
-
super(*args).tap do |result|
|
|
15
|
-
Bullet::Detector::NPlusOneQuery.add_impossible_object(self) if result && was_new_record
|
|
5
|
+
def _create_record(*)
|
|
6
|
+
super do
|
|
7
|
+
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
|
|
8
|
+
yield(self) if block_given?
|
|
16
9
|
end
|
|
17
10
|
end
|
|
18
11
|
end
|
|
@@ -82,6 +75,7 @@ module Bullet
|
|
|
82
75
|
# add includes in scope
|
|
83
76
|
def find_with_associations
|
|
84
77
|
return super { |r| yield r } if block_given?
|
|
78
|
+
|
|
85
79
|
records = super
|
|
86
80
|
if Bullet.start?
|
|
87
81
|
associations = (eager_load_values + includes_values).uniq
|
|
@@ -115,6 +109,7 @@ module Bullet
|
|
|
115
109
|
key = aliases.column_alias(node, node.primary_key)
|
|
116
110
|
id = row[key]
|
|
117
111
|
next unless id.nil?
|
|
112
|
+
|
|
118
113
|
associations = node.reflection.name
|
|
119
114
|
Bullet::Detector::Association.add_object_associations(ar_parent, associations)
|
|
120
115
|
Bullet::Detector::NPlusOneQuery.call_association(ar_parent, associations)
|
|
@@ -151,11 +146,15 @@ module Bullet
|
|
|
151
146
|
|
|
152
147
|
if Bullet.start?
|
|
153
148
|
if is_a? ::ActiveRecord::Associations::ThroughAssociation
|
|
154
|
-
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
|
|
155
|
-
association = owner.association through_reflection.name
|
|
149
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.through_reflection.name)
|
|
150
|
+
association = owner.association reflection.through_reflection.name
|
|
156
151
|
Array(association.target).each do |through_record|
|
|
157
152
|
Bullet::Detector::NPlusOneQuery.call_association(through_record, source_reflection.name)
|
|
158
153
|
end
|
|
154
|
+
|
|
155
|
+
if reflection.through_reflection != through_reflection
|
|
156
|
+
Bullet::Detector::NPlusOneQuery.call_association(owner, through_reflection.name)
|
|
157
|
+
end
|
|
159
158
|
end
|
|
160
159
|
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name) unless @inversed
|
|
161
160
|
if records.first.class.name !~ /^HABTM_/
|