bullet 5.7.0 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.rails-5.2 +1 -1
- data/Guardfile +1 -1
- data/README.md +3 -0
- data/Rakefile +4 -4
- data/bullet.gemspec +2 -3
- data/lib/bullet.rb +23 -23
- data/lib/bullet/active_record4.rb +3 -1
- data/lib/bullet/active_record41.rb +1 -1
- data/lib/bullet/active_record42.rb +8 -9
- data/lib/bullet/active_record5.rb +27 -28
- data/lib/bullet/active_record52.rb +27 -28
- data/lib/bullet/detector/association.rb +12 -12
- data/lib/bullet/detector/counter_cache.rb +7 -7
- data/lib/bullet/detector/n_plus_one_query.rb +6 -6
- data/lib/bullet/detector/unused_eager_loading.rb +23 -21
- data/lib/bullet/ext/object.rb +4 -4
- data/lib/bullet/ext/string.rb +1 -1
- data/lib/bullet/notification/base.rb +14 -14
- data/lib/bullet/notification/n_plus_one_query.rb +4 -4
- data/lib/bullet/notification/unused_eager_loading.rb +4 -4
- data/lib/bullet/notification_collector.rb +0 -1
- data/lib/bullet/version.rb +1 -2
- data/perf/benchmark.rb +7 -7
- data/spec/bullet/detector/n_plus_one_query_spec.rb +8 -8
- data/spec/bullet/ext/object_spec.rb +1 -1
- data/spec/bullet/notification/base_spec.rb +6 -6
- data/spec/bullet/notification/counter_cache_spec.rb +1 -1
- data/spec/bullet/notification/n_plus_one_query_spec.rb +1 -1
- data/spec/bullet/notification/unused_eager_loading_spec.rb +1 -1
- data/spec/bullet/rack_spec.rb +9 -10
- data/spec/bullet/registry/association_spec.rb +2 -2
- data/spec/bullet/registry/base_spec.rb +3 -3
- data/spec/bullet_spec.rb +7 -7
- data/spec/integration/active_record/association_spec.rb +16 -16
- data/spec/integration/counter_cache_spec.rb +2 -2
- data/spec/models/mongoid/address.rb +1 -1
- data/spec/models/mongoid/category.rb +2 -2
- data/spec/models/mongoid/comment.rb +1 -1
- data/spec/models/mongoid/company.rb +1 -1
- data/spec/models/mongoid/entry.rb +1 -1
- data/spec/models/mongoid/post.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/support/mongo_seed.rb +23 -23
- data/spec/support/rack_double.rb +7 -16
- data/spec/support/sqlite_seed.rb +73 -73
- metadata +5 -5
data/spec/support/rack_double.rb
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
module Support
|
2
2
|
class AppDouble
|
3
|
-
def call
|
3
|
+
def call(_env)
|
4
4
|
env = @env
|
5
5
|
[status, headers, response]
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
@status = status
|
10
|
-
end
|
8
|
+
attr_writer :status
|
11
9
|
|
12
|
-
|
13
|
-
@headers = headers
|
14
|
-
end
|
10
|
+
attr_writer :headers
|
15
11
|
|
16
12
|
def headers
|
17
13
|
@headers ||= { 'Content-Type' => 'text/html' }
|
18
14
|
@headers
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
@response = response
|
23
|
-
end
|
17
|
+
attr_writer :response
|
24
18
|
|
25
19
|
private
|
26
20
|
|
@@ -34,7 +28,7 @@ module Support
|
|
34
28
|
end
|
35
29
|
|
36
30
|
class ResponseDouble
|
37
|
-
def initialize
|
31
|
+
def initialize(actual_body = nil)
|
38
32
|
@actual_body = actual_body
|
39
33
|
end
|
40
34
|
|
@@ -42,15 +36,12 @@ module Support
|
|
42
36
|
@body ||= '<html><head></head><body></body></html>'
|
43
37
|
end
|
44
38
|
|
45
|
-
|
46
|
-
@body = body
|
47
|
-
end
|
39
|
+
attr_writer :body
|
48
40
|
|
49
41
|
def each
|
50
42
|
yield body
|
51
43
|
end
|
52
44
|
|
53
|
-
def close
|
54
|
-
end
|
45
|
+
def close; end
|
55
46
|
end
|
56
47
|
end
|
data/spec/support/sqlite_seed.rb
CHANGED
@@ -1,100 +1,100 @@
|
|
1
1
|
module Support
|
2
2
|
module SqliteSeed
|
3
3
|
def seed_db
|
4
|
-
newspaper1 = Newspaper.create(:
|
5
|
-
newspaper2 = Newspaper.create(:
|
6
|
-
|
7
|
-
writer1 = Writer.create(:
|
8
|
-
writer2 = Writer.create(:
|
9
|
-
user1 = BaseUser.create(:
|
10
|
-
user2 = BaseUser.create(:
|
11
|
-
|
12
|
-
category1 = Category.create(:
|
13
|
-
category2 = Category.create(:
|
14
|
-
|
15
|
-
post1 = category1.posts.create(:
|
16
|
-
post1a = category1.posts.create(:
|
17
|
-
post2 = category2.posts.create(:
|
18
|
-
post3 = category2.posts.create(:
|
19
|
-
|
20
|
-
comment1 = post1.comments.create(:
|
21
|
-
comment2 = post1.comments.create(:
|
22
|
-
comment3 = post1.comments.create(:
|
23
|
-
comment4 = post1.comments.create(:
|
24
|
-
comment8 = post1a.comments.create(:
|
25
|
-
comment9 = post1a.comments.create(:
|
26
|
-
comment5 = post2.comments.create(:
|
27
|
-
comment6 = post2.comments.create(:
|
28
|
-
comment7 = post2.comments.create(:
|
29
|
-
|
30
|
-
entry1 = category1.entries.create(:
|
31
|
-
entry2 = category1.entries.create(:
|
32
|
-
|
33
|
-
student1 = Student.create(:
|
34
|
-
student2 = Student.create(:
|
35
|
-
teacher1 = Teacher.create(:
|
36
|
-
teacher2 = Teacher.create(:
|
4
|
+
newspaper1 = Newspaper.create(name: 'First Newspaper')
|
5
|
+
newspaper2 = Newspaper.create(name: 'Second Newspaper')
|
6
|
+
|
7
|
+
writer1 = Writer.create(name: 'first', newspaper: newspaper1)
|
8
|
+
writer2 = Writer.create(name: 'second', newspaper: newspaper2)
|
9
|
+
user1 = BaseUser.create(name: 'third', newspaper: newspaper1)
|
10
|
+
user2 = BaseUser.create(name: 'fourth', newspaper: newspaper2)
|
11
|
+
|
12
|
+
category1 = Category.create(name: 'first')
|
13
|
+
category2 = Category.create(name: 'second')
|
14
|
+
|
15
|
+
post1 = category1.posts.create(name: 'first', writer: writer1)
|
16
|
+
post1a = category1.posts.create(name: 'like first', writer: writer2, active: false)
|
17
|
+
post2 = category2.posts.create(name: 'second', writer: writer2)
|
18
|
+
post3 = category2.posts.create(name: 'third', writer: writer2)
|
19
|
+
|
20
|
+
comment1 = post1.comments.create(name: 'first', author: writer1)
|
21
|
+
comment2 = post1.comments.create(name: 'first2', author: writer1)
|
22
|
+
comment3 = post1.comments.create(name: 'first3', author: writer1)
|
23
|
+
comment4 = post1.comments.create(name: 'second', author: writer2)
|
24
|
+
comment8 = post1a.comments.create(name: 'like first 1', author: writer1)
|
25
|
+
comment9 = post1a.comments.create(name: 'like first 2', author: writer2)
|
26
|
+
comment5 = post2.comments.create(name: 'third', author: user1)
|
27
|
+
comment6 = post2.comments.create(name: 'fourth', author: user2)
|
28
|
+
comment7 = post2.comments.create(name: 'fourth', author: writer1)
|
29
|
+
|
30
|
+
entry1 = category1.entries.create(name: 'first')
|
31
|
+
entry2 = category1.entries.create(name: 'second')
|
32
|
+
|
33
|
+
student1 = Student.create(name: 'first')
|
34
|
+
student2 = Student.create(name: 'second')
|
35
|
+
teacher1 = Teacher.create(name: 'first')
|
36
|
+
teacher2 = Teacher.create(name: 'second')
|
37
37
|
student1.teachers = [teacher1, teacher2]
|
38
38
|
student2.teachers = [teacher1, teacher2]
|
39
39
|
teacher1.students << student1
|
40
40
|
teacher2.students << student2
|
41
41
|
|
42
|
-
firm1 = Firm.create(:
|
43
|
-
firm2 = Firm.create(:
|
44
|
-
client1 = Client.create(:
|
45
|
-
client2 = Client.create(:
|
42
|
+
firm1 = Firm.create(name: 'first')
|
43
|
+
firm2 = Firm.create(name: 'second')
|
44
|
+
client1 = Client.create(name: 'first')
|
45
|
+
client2 = Client.create(name: 'second')
|
46
46
|
firm1.clients = [client1, client2]
|
47
47
|
firm2.clients = [client1, client2]
|
48
48
|
client1.firms << firm1
|
49
49
|
client2.firms << firm2
|
50
50
|
|
51
|
-
company1 = Company.create(:
|
52
|
-
company2 = Company.create(:
|
51
|
+
company1 = Company.create(name: 'first')
|
52
|
+
company2 = Company.create(name: 'second')
|
53
53
|
|
54
|
-
Address.create(:
|
55
|
-
Address.create(:
|
54
|
+
Address.create(name: 'first', company: company1)
|
55
|
+
Address.create(name: 'second', company: company2)
|
56
56
|
|
57
|
-
country1 = Country.create(:
|
58
|
-
country2 = Country.create(:
|
57
|
+
country1 = Country.create(name: 'first')
|
58
|
+
country2 = Country.create(name: 'second')
|
59
59
|
|
60
|
-
country1.cities.create(:
|
61
|
-
country1.cities.create(:
|
62
|
-
country2.cities.create(:
|
63
|
-
country2.cities.create(:
|
60
|
+
country1.cities.create(name: 'first')
|
61
|
+
country1.cities.create(name: 'second')
|
62
|
+
country2.cities.create(name: 'third')
|
63
|
+
country2.cities.create(name: 'fourth')
|
64
64
|
|
65
|
-
person1 = Person.create(:
|
66
|
-
person2 = Person.create(:
|
65
|
+
person1 = Person.create(name: 'first')
|
66
|
+
person2 = Person.create(name: 'second')
|
67
67
|
|
68
|
-
person1.pets.create(:
|
69
|
-
person1.pets.create(:
|
70
|
-
person2.pets.create(:
|
71
|
-
person2.pets.create(:
|
68
|
+
person1.pets.create(name: 'first')
|
69
|
+
person1.pets.create(name: 'second')
|
70
|
+
person2.pets.create(name: 'third')
|
71
|
+
person2.pets.create(name: 'fourth')
|
72
72
|
|
73
|
-
author1 = Author.create(:
|
74
|
-
author2 = Author.create(:
|
75
|
-
folder1 = Folder.create(:
|
76
|
-
folder2 = Folder.create(:
|
77
|
-
page1 = Page.create(:
|
78
|
-
page2 = Page.create(:
|
79
|
-
page3 = Page.create(:
|
80
|
-
page4 = Page.create(:
|
73
|
+
author1 = Author.create(name: 'author1')
|
74
|
+
author2 = Author.create(name: 'author2')
|
75
|
+
folder1 = Folder.create(name: 'folder1', author_id: author1.id)
|
76
|
+
folder2 = Folder.create(name: 'folder2', author_id: author2.id)
|
77
|
+
page1 = Page.create(name: 'page1', parent_id: folder1.id, author_id: author1.id)
|
78
|
+
page2 = Page.create(name: 'page2', parent_id: folder1.id, author_id: author1.id)
|
79
|
+
page3 = Page.create(name: 'page3', parent_id: folder2.id, author_id: author2.id)
|
80
|
+
page4 = Page.create(name: 'page4', parent_id: folder2.id, author_id: author2.id)
|
81
81
|
|
82
|
-
user1 = User.create(:
|
83
|
-
user2 = User.create(:
|
82
|
+
user1 = User.create(name: 'user1', category: category1)
|
83
|
+
user2 = User.create(name: 'user2', category: category1)
|
84
84
|
|
85
|
-
submission1 = user1.create_submission(:
|
86
|
-
submission2 = user2.create_submission(:
|
85
|
+
submission1 = user1.create_submission(name: 'submission1')
|
86
|
+
submission2 = user2.create_submission(name: 'submission2')
|
87
87
|
|
88
|
-
submission1.replies.create(:
|
89
|
-
submission1.replies.create(:
|
90
|
-
submission2.replies.create(:
|
91
|
-
submission2.replies.create(:
|
88
|
+
submission1.replies.create(name: 'reply1')
|
89
|
+
submission1.replies.create(name: 'reply2')
|
90
|
+
submission2.replies.create(name: 'reply3')
|
91
|
+
submission2.replies.create(name: 'reply4')
|
92
92
|
end
|
93
93
|
|
94
94
|
def setup_db
|
95
|
-
ActiveRecord::Base.establish_connection(:
|
95
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
96
96
|
|
97
|
-
ActiveRecord::Schema.define(:
|
97
|
+
ActiveRecord::Schema.define(version: 1) do
|
98
98
|
create_table :addresses do |t|
|
99
99
|
t.column :name, :string
|
100
100
|
t.column :company_id, :integer
|
@@ -194,7 +194,7 @@ module Support
|
|
194
194
|
t.column :name, :string
|
195
195
|
t.column :category_id, :integer
|
196
196
|
t.column :writer_id, :integer
|
197
|
-
t.column :active, :boolean, :
|
197
|
+
t.column :active, :boolean, default: true
|
198
198
|
end
|
199
199
|
|
200
200
|
create_table :relationships do |t|
|
@@ -206,7 +206,7 @@ module Support
|
|
206
206
|
t.column :name, :string
|
207
207
|
end
|
208
208
|
|
209
|
-
create_table :students_teachers, :
|
209
|
+
create_table :students_teachers, id: false do |t|
|
210
210
|
t.column :student_id, :integer
|
211
211
|
t.column :teacher_id, :integer
|
212
212
|
end
|
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.7.
|
4
|
+
version: 5.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-07 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.
|
33
|
+
version: 1.11.0
|
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.
|
40
|
+
version: 1.11.0
|
41
41
|
description: help to kill N+1 queries and unused eager loading.
|
42
42
|
email:
|
43
43
|
- flyerhzm@gmail.com
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: 1.3.6
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.6.
|
183
|
+
rubygems_version: 2.6.14
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: help to kill N+1 queries and unused eager loading.
|