bulletmark_repairer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/lib/bulletmark_repairer/{bulletmark_repairer.rb → application_associations.rb} +0 -12
- data/lib/bulletmark_repairer/associations_builder.rb +13 -6
- data/lib/bulletmark_repairer/patcher.rb +1 -1
- data/lib/bulletmark_repairer/rack.rb +1 -2
- data/lib/bulletmark_repairer/version.rb +1 -1
- data/lib/bulletmark_repairer.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 533eed3a74c78c89236e5c1355f588814c6a4017cf79af12f0a0e23fe030fcde
|
4
|
+
data.tar.gz: bf8a718e822ba241ab3299f675db3809870d955257bc5279644285373a619141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a33cc9ba73a76ebca97b8293677d8498761a07c2a6680e5182a65b2d8f7cb6237196506aedee63ed4f798168beb4161072ee5e62cbcee9506c4040e4584a508f
|
7
|
+
data.tar.gz: 2fb1af553ee13ca638023120306f6284b4d04ae567171616cee658ee5277f1bb33a589d769d7625ad0d6b445d06664a068dc49db479e8ac91934d36aef3553d6
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
## [0.1.2] - 2023-10-16
|
2
|
+
|
3
|
+
- Reduce dependencies [#1](https://github.com/makicamel/bulletmark_repairer/pull/1) [@tricknotes]()
|
4
|
+
- Stop using class instance variables for thread safe [024f6c5](https://github.com/makicamel/bulletmark_repairer/commit/024f6c53f82b182a998c1e43de48d8c6c9ce5bf3)
|
5
|
+
|
1
6
|
## [0.1.1] - 2023-10-11
|
2
7
|
|
3
|
-
- Support Ruby 3.0 dbdf27c6c9a7259ad9474153d2394da5bac45b43
|
8
|
+
- Support Ruby 3.0 [dbdf27c](https://github.com/makicamel/bulletmark_repairer/commit/dbdf27c6c9a7259ad9474153d2394da5bac45b43)
|
4
9
|
|
5
10
|
## [0.1.0] - 2023-10-10
|
6
11
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ BulletmarkRepairer is an auto corrector for N+1 queries detected at runtime on R
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'bulletmark_repairer', group
|
10
|
+
gem 'bulletmark_repairer', group: %w(development test)
|
11
11
|
```
|
12
12
|
|
13
13
|
## Usage
|
@@ -1,18 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BulletmarkRepairer
|
4
|
-
def self.associations
|
5
|
-
@associations ||= ApplicationAssociations.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.key(target_klass_name, base_klass_name, candidates)
|
9
|
-
associations.key(target_klass_name, base_klass_name, candidates)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.reset_associations
|
13
|
-
@associations = nil
|
14
|
-
end
|
15
|
-
|
16
4
|
class ApplicationAssociations
|
17
5
|
def key(target_klass_name, base_klass_name, candidates)
|
18
6
|
key = target_klass_name.underscore
|
@@ -10,13 +10,19 @@ module BulletmarkRepairer
|
|
10
10
|
if associations[marker.index]
|
11
11
|
associations[marker.index].add(marker)
|
12
12
|
else
|
13
|
-
associations[marker.index] = Associations.new(marker)
|
13
|
+
associations[marker.index] = Associations.new(marker, @application_associations)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def associations
|
18
18
|
@associations ||= {}
|
19
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@application_associations = BulletmarkRepairer::ApplicationAssociations.new
|
25
|
+
end
|
20
26
|
end
|
21
27
|
|
22
28
|
class Associations
|
@@ -38,9 +44,10 @@ module BulletmarkRepairer
|
|
38
44
|
|
39
45
|
private
|
40
46
|
|
41
|
-
def initialize(marker)
|
47
|
+
def initialize(marker, application_associations)
|
42
48
|
@marker = marker
|
43
49
|
@associations = { base: marker.associations }
|
50
|
+
@application_associations = application_associations
|
44
51
|
end
|
45
52
|
|
46
53
|
# @return [Hash, nil]
|
@@ -66,12 +73,12 @@ module BulletmarkRepairer
|
|
66
73
|
def formed_key(marker:, associations:)
|
67
74
|
case associations
|
68
75
|
when Hash
|
69
|
-
|
70
|
-
|
76
|
+
@application_associations.key(marker.base_class, @marker.base_class, associations.keys) ||
|
77
|
+
@application_associations.key(marker.base_class, @marker.base_class, associations.values.flatten)
|
71
78
|
when Array
|
72
|
-
|
79
|
+
@application_associations.key(marker.base_class, @marker.base_class, associations)
|
73
80
|
else # Symbol, String
|
74
|
-
|
81
|
+
@application_associations.key(marker.base_class, @marker.base_class, [associations])
|
75
82
|
end
|
76
83
|
end
|
77
84
|
|
@@ -5,7 +5,7 @@ require 'securerandom'
|
|
5
5
|
require 'parser/runner/ruby_rewrite'
|
6
6
|
|
7
7
|
module BulletmarkRepairer
|
8
|
-
class
|
8
|
+
class Patcher
|
9
9
|
def self.execute(notifications:, controller:, action:)
|
10
10
|
new(notifications: notifications, controller: controller, action: action).execute
|
11
11
|
end
|
@@ -7,12 +7,11 @@ module BulletmarkRepairer
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
BulletmarkRepairer.reset_associations
|
11
10
|
@app.call(env)
|
12
11
|
ensure
|
13
12
|
begin
|
14
13
|
if Thread.current[:bullet_notification_collector].notifications_present?
|
15
|
-
BulletmarkRepairer::
|
14
|
+
BulletmarkRepairer::Patcher.execute(
|
16
15
|
notifications: Thread.current[:bullet_notification_collector],
|
17
16
|
controller: env['action_dispatch.request.parameters']['controller'],
|
18
17
|
action: env['action_dispatch.request.parameters']['action']
|
data/lib/bulletmark_repairer.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'bulletmark_repairer/version'
|
4
4
|
require 'bulletmark_repairer/railtie' if ENV['REPAIR']
|
5
|
-
require 'bulletmark_repairer/
|
5
|
+
require 'bulletmark_repairer/application_associations'
|
6
6
|
require 'bulletmark_repairer/associations_builder'
|
7
7
|
require 'bulletmark_repairer/configuration'
|
8
8
|
require 'bulletmark_repairer/corrector_builder'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulletmark_repairer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- makicamel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bullet
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,7 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: railties
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -68,8 +82,8 @@ files:
|
|
68
82
|
- README.md
|
69
83
|
- Rakefile
|
70
84
|
- lib/bulletmark_repairer.rb
|
85
|
+
- lib/bulletmark_repairer/application_associations.rb
|
71
86
|
- lib/bulletmark_repairer/associations_builder.rb
|
72
|
-
- lib/bulletmark_repairer/bulletmark_repairer.rb
|
73
87
|
- lib/bulletmark_repairer/configuration.rb
|
74
88
|
- lib/bulletmark_repairer/controller_corrector.rb
|
75
89
|
- lib/bulletmark_repairer/corrector.rb
|