bullet 5.7.4 → 5.8.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 +8 -11
- data/Gemfile.rails-5.2 +1 -1
- data/README.md +7 -4
- data/Rakefile +1 -1
- data/bullet.gemspec +9 -3
- data/lib/bullet/active_record4.rb +15 -13
- data/lib/bullet/active_record41.rb +15 -13
- data/lib/bullet/active_record42.rb +16 -13
- data/lib/bullet/active_record5.rb +26 -13
- data/lib/bullet/active_record52.rb +21 -13
- data/lib/bullet/dependency.rb +3 -1
- data/lib/bullet/detector/association.rb +4 -2
- data/lib/bullet/detector/base.rb +2 -0
- data/lib/bullet/detector/counter_cache.rb +3 -0
- data/lib/bullet/detector/n_plus_one_query.rb +11 -9
- data/lib/bullet/detector/unused_eager_loading.rb +3 -0
- data/lib/bullet/detector.rb +2 -0
- data/lib/bullet/ext/object.rb +3 -1
- data/lib/bullet/ext/string.rb +3 -1
- data/lib/bullet/mongoid4x.rb +7 -2
- data/lib/bullet/mongoid5x.rb +7 -2
- data/lib/bullet/mongoid6x.rb +7 -4
- data/lib/bullet/notification/base.rb +3 -1
- data/lib/bullet/notification/counter_cache.rb +2 -0
- data/lib/bullet/notification/n_plus_one_query.rb +2 -0
- data/lib/bullet/notification/unused_eager_loading.rb +2 -0
- data/lib/bullet/notification.rb +2 -0
- data/lib/bullet/notification_collector.rb +2 -0
- data/lib/bullet/rack.rb +19 -15
- data/lib/bullet/registry/association.rb +2 -0
- data/lib/bullet/registry/base.rb +2 -0
- data/lib/bullet/registry/object.rb +2 -0
- data/lib/bullet/registry.rb +2 -0
- data/lib/bullet/stack_trace_filter.rb +43 -22
- data/lib/bullet/version.rb +3 -1
- data/lib/bullet.rb +5 -2
- data/lib/generators/bullet/install_generator.rb +5 -3
- data/perf/benchmark.rb +2 -0
- data/rails/init.rb +2 -0
- data/spec/bullet/detector/association_spec.rb +2 -0
- data/spec/bullet/detector/base_spec.rb +2 -0
- data/spec/bullet/detector/counter_cache_spec.rb +2 -0
- data/spec/bullet/detector/n_plus_one_query_spec.rb +25 -0
- data/spec/bullet/detector/unused_eager_loading_spec.rb +2 -0
- data/spec/bullet/ext/object_spec.rb +2 -0
- data/spec/bullet/ext/string_spec.rb +2 -0
- data/spec/bullet/notification/base_spec.rb +2 -0
- data/spec/bullet/notification/counter_cache_spec.rb +2 -0
- data/spec/bullet/notification/n_plus_one_query_spec.rb +2 -0
- data/spec/bullet/notification/unused_eager_loading_spec.rb +2 -0
- data/spec/bullet/notification_collector_spec.rb +2 -0
- data/spec/bullet/rack_spec.rb +2 -0
- data/spec/bullet/registry/association_spec.rb +2 -0
- data/spec/bullet/registry/base_spec.rb +2 -0
- data/spec/bullet/registry/object_spec.rb +2 -0
- data/spec/bullet_spec.rb +2 -0
- data/spec/integration/active_record/association_spec.rb +63 -1
- data/spec/integration/counter_cache_spec.rb +2 -0
- data/spec/integration/mongoid/association_spec.rb +2 -0
- data/spec/models/address.rb +2 -0
- data/spec/models/author.rb +2 -0
- data/spec/models/base_user.rb +2 -0
- data/spec/models/category.rb +2 -0
- data/spec/models/city.rb +2 -0
- data/spec/models/client.rb +4 -0
- data/spec/models/comment.rb +2 -0
- data/spec/models/company.rb +2 -0
- data/spec/models/country.rb +2 -0
- data/spec/models/document.rb +2 -0
- data/spec/models/entry.rb +2 -0
- data/spec/models/firm.rb +3 -0
- data/spec/models/folder.rb +2 -0
- data/spec/models/group.rb +4 -0
- data/spec/models/mongoid/address.rb +2 -0
- data/spec/models/mongoid/category.rb +2 -0
- data/spec/models/mongoid/comment.rb +2 -0
- data/spec/models/mongoid/company.rb +2 -0
- data/spec/models/mongoid/entry.rb +2 -0
- data/spec/models/mongoid/post.rb +2 -0
- data/spec/models/mongoid/user.rb +2 -0
- data/spec/models/newspaper.rb +2 -0
- data/spec/models/page.rb +2 -0
- data/spec/models/person.rb +2 -0
- data/spec/models/pet.rb +2 -0
- data/spec/models/post.rb +17 -0
- data/spec/models/relationship.rb +2 -0
- data/spec/models/reply.rb +2 -0
- data/spec/models/student.rb +2 -0
- data/spec/models/submission.rb +2 -0
- data/spec/models/teacher.rb +2 -0
- data/spec/models/user.rb +2 -0
- data/spec/models/writer.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/bullet_ext.rb +2 -0
- data/spec/support/mongo_seed.rb +4 -2
- data/spec/support/rack_double.rb +2 -0
- data/spec/support/sqlite_seed.rb +13 -4
- data/tasks/bullet_tasks.rake +2 -0
- metadata +9 -5
data/spec/models/comment.rb
CHANGED
data/spec/models/company.rb
CHANGED
data/spec/models/country.rb
CHANGED
data/spec/models/document.rb
CHANGED
data/spec/models/entry.rb
CHANGED
data/spec/models/firm.rb
CHANGED
data/spec/models/folder.rb
CHANGED
data/spec/models/mongoid/post.rb
CHANGED
data/spec/models/mongoid/user.rb
CHANGED
data/spec/models/newspaper.rb
CHANGED
data/spec/models/page.rb
CHANGED
data/spec/models/person.rb
CHANGED
data/spec/models/pet.rb
CHANGED
data/spec/models/post.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Post < ActiveRecord::Base
|
|
2
4
|
belongs_to :category, inverse_of: :posts
|
|
3
5
|
belongs_to :writer
|
|
@@ -12,4 +14,19 @@ class Post < ActiveRecord::Base
|
|
|
12
14
|
def link=(*)
|
|
13
15
|
comments.new
|
|
14
16
|
end
|
|
17
|
+
|
|
18
|
+
# see association_spec.rb 'should not detect newly assigned object in an after_save'
|
|
19
|
+
attr_accessor :trigger_after_save
|
|
20
|
+
after_save do
|
|
21
|
+
next unless trigger_after_save
|
|
22
|
+
|
|
23
|
+
temp_comment = Comment.new(post: self)
|
|
24
|
+
# this triggers self to be "possible", even though it's
|
|
25
|
+
# not saved yet
|
|
26
|
+
temp_comment.post
|
|
27
|
+
|
|
28
|
+
# category should NOT whine about not being pre-loaded, because
|
|
29
|
+
# it's obviously attached to a new object
|
|
30
|
+
category
|
|
31
|
+
end
|
|
15
32
|
end
|
data/spec/models/relationship.rb
CHANGED
data/spec/models/reply.rb
CHANGED
data/spec/models/student.rb
CHANGED
data/spec/models/submission.rb
CHANGED
data/spec/models/teacher.rb
CHANGED
data/spec/models/user.rb
CHANGED
data/spec/models/writer.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/bullet_ext.rb
CHANGED
data/spec/support/mongo_seed.rb
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Support
|
|
2
4
|
module MongoSeed
|
|
5
|
+
module_function
|
|
6
|
+
|
|
3
7
|
def seed_db
|
|
4
8
|
category1 = Mongoid::Category.create(name: 'first')
|
|
5
9
|
category2 = Mongoid::Category.create(name: 'second')
|
|
@@ -64,7 +68,5 @@ module Support
|
|
|
64
68
|
Mongoid.purge!
|
|
65
69
|
Mongoid::IdentityMap.clear if Mongoid.const_defined?(:IdentityMap)
|
|
66
70
|
end
|
|
67
|
-
|
|
68
|
-
module_function
|
|
69
71
|
end
|
|
70
72
|
end
|
data/spec/support/rack_double.rb
CHANGED
data/spec/support/sqlite_seed.rb
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Support
|
|
2
4
|
module SqliteSeed
|
|
5
|
+
module_function
|
|
6
|
+
|
|
3
7
|
def seed_db
|
|
4
8
|
newspaper1 = Newspaper.create(name: 'First Newspaper')
|
|
5
9
|
newspaper2 = Newspaper.create(name: 'Second Newspaper')
|
|
@@ -41,8 +45,10 @@ module Support
|
|
|
41
45
|
|
|
42
46
|
firm1 = Firm.create(name: 'first')
|
|
43
47
|
firm2 = Firm.create(name: 'second')
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
group1 = Group.create(name: 'first')
|
|
49
|
+
group2 = Group.create(name: 'second')
|
|
50
|
+
client1 = Client.create(name: 'first', group: group1)
|
|
51
|
+
client2 = Client.create(name: 'second', group: group2)
|
|
46
52
|
firm1.clients = [client1, client2]
|
|
47
53
|
firm2.clients = [client1, client2]
|
|
48
54
|
client1.firms << firm1
|
|
@@ -121,6 +127,7 @@ module Support
|
|
|
121
127
|
|
|
122
128
|
create_table :clients do |t|
|
|
123
129
|
t.column :name, :string
|
|
130
|
+
t.column :group_id, :integer
|
|
124
131
|
end
|
|
125
132
|
|
|
126
133
|
create_table :comments do |t|
|
|
@@ -167,6 +174,10 @@ module Support
|
|
|
167
174
|
t.column :name, :string
|
|
168
175
|
end
|
|
169
176
|
|
|
177
|
+
create_table :groups do |t|
|
|
178
|
+
t.column :name, :string
|
|
179
|
+
end
|
|
180
|
+
|
|
170
181
|
create_table :hotels do |t|
|
|
171
182
|
t.column :name, :string
|
|
172
183
|
t.column :location_id, :integer
|
|
@@ -231,7 +242,5 @@ module Support
|
|
|
231
242
|
end
|
|
232
243
|
end
|
|
233
244
|
end
|
|
234
|
-
|
|
235
|
-
module_function
|
|
236
245
|
end
|
|
237
246
|
end
|
data/tasks/bullet_tasks.rake
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bullet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Huang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.11
|
|
33
|
+
version: '1.11'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.11
|
|
40
|
+
version: '1.11'
|
|
41
41
|
description: help to kill N+1 queries and unused eager loading.
|
|
42
42
|
email:
|
|
43
43
|
- flyerhzm@gmail.com
|
|
@@ -133,6 +133,7 @@ files:
|
|
|
133
133
|
- spec/models/entry.rb
|
|
134
134
|
- spec/models/firm.rb
|
|
135
135
|
- spec/models/folder.rb
|
|
136
|
+
- spec/models/group.rb
|
|
136
137
|
- spec/models/mongoid/address.rb
|
|
137
138
|
- spec/models/mongoid/category.rb
|
|
138
139
|
- spec/models/mongoid/comment.rb
|
|
@@ -163,7 +164,9 @@ files:
|
|
|
163
164
|
homepage: https://github.com/flyerhzm/bullet
|
|
164
165
|
licenses:
|
|
165
166
|
- MIT
|
|
166
|
-
metadata:
|
|
167
|
+
metadata:
|
|
168
|
+
changelog_uri: https://github.com/flyerhzm/bullet/blob/master/CHANGELOG.md
|
|
169
|
+
source_code_uri: https://github.com/flyerhzm/bullet
|
|
167
170
|
post_install_message:
|
|
168
171
|
rdoc_options: []
|
|
169
172
|
require_paths:
|
|
@@ -218,6 +221,7 @@ test_files:
|
|
|
218
221
|
- spec/models/entry.rb
|
|
219
222
|
- spec/models/firm.rb
|
|
220
223
|
- spec/models/folder.rb
|
|
224
|
+
- spec/models/group.rb
|
|
221
225
|
- spec/models/mongoid/address.rb
|
|
222
226
|
- spec/models/mongoid/category.rb
|
|
223
227
|
- spec/models/mongoid/comment.rb
|