n_1_finder 0.0.2
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 +7 -0
- data/Readme.md +74 -0
- data/lib/n_1_finder.rb +111 -0
- data/lib/n_1_finder/adapters/active_record_adapter.rb +49 -0
- data/lib/n_1_finder/adapters/base_adapter.rb +46 -0
- data/lib/n_1_finder/adapters/null_adapter.rb +16 -0
- data/lib/n_1_finder/adapters/sequel_adapter.rb +33 -0
- data/lib/n_1_finder/logger.rb +56 -0
- data/lib/n_1_finder/middleware.rb +13 -0
- data/lib/n_1_finder/n_1_query.rb +38 -0
- data/lib/n_1_finder/query.rb +57 -0
- data/lib/n_1_finder/storage.rb +23 -0
- data/lib/n_1_finder/version.rb +4 -0
- data/spec/n_1_finder/adapters/active_record_adapter_spec.rb +37 -0
- data/spec/n_1_finder/adapters/null_adapter_spec.rb +5 -0
- data/spec/n_1_finder/adapters/sequel_adapter_spec.rb +5 -0
- data/spec/n_1_finder/features/active_record_mysql_spec.rb +12 -0
- data/spec/n_1_finder/features/active_record_postgres_spec.rb +12 -0
- data/spec/n_1_finder/features/active_record_sqlite_spec.rb +12 -0
- data/spec/n_1_finder/features/sequel_mysql_spec.rb +12 -0
- data/spec/n_1_finder/features/sequel_postgres_spec.rb +13 -0
- data/spec/n_1_finder/features/sequel_sqlite_spec.rb +12 -0
- data/spec/n_1_finder/logger_spec.rb +40 -0
- data/spec/n_1_finder/middleware_spec.rb +15 -0
- data/spec/n_1_finder/n_1_query_spec.rb +28 -0
- data/spec/n_1_finder/query_spec.rb +81 -0
- data/spec/n_1_finder/storage_spec.rb +23 -0
- data/spec/n_1_finder_spec.rb +67 -0
- data/spec/secrets.yml.example +9 -0
- data/spec/shared_examples/adapter.rb +37 -0
- data/spec/spec_helper.rb +61 -0
- data/spec/support/n_1_helpers.rb +56 -0
- data/spec/support/orm_helpers.rb +89 -0
- data/spec/support/test_active_record_migration.rb +46 -0
- data/spec/support/test_active_record_models.rb +56 -0
- data/spec/support/test_no_connection_models.rb +57 -0
- data/spec/support/test_sequel_migration.rb +39 -0
- data/spec/support/test_sequel_models.rb +65 -0
- metadata +81 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
module TestSequelModels
|
2
|
+
def users_class
|
3
|
+
@users_class ||= begin
|
4
|
+
posts = posts_class
|
5
|
+
result = Class.new(Sequel::Model(:users)) do
|
6
|
+
def self.name
|
7
|
+
'User'
|
8
|
+
end
|
9
|
+
|
10
|
+
one_to_many :posts, class: posts
|
11
|
+
end
|
12
|
+
|
13
|
+
use_current_db(result)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def posts_class
|
18
|
+
@posts_class ||= begin
|
19
|
+
documents = documents_class
|
20
|
+
result = Class.new(Sequel::Model(:posts)) do
|
21
|
+
def self.name
|
22
|
+
'Post'
|
23
|
+
end
|
24
|
+
|
25
|
+
one_to_one :document, class: documents
|
26
|
+
end
|
27
|
+
|
28
|
+
use_current_db(result)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def documents_class
|
33
|
+
@documents_class ||= begin
|
34
|
+
links = links_class
|
35
|
+
result = Class.new(Sequel::Model(:documents)) do
|
36
|
+
def self.name
|
37
|
+
'Document'
|
38
|
+
end
|
39
|
+
|
40
|
+
one_to_many :links, class: links
|
41
|
+
end
|
42
|
+
|
43
|
+
use_current_db(result)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def links_class
|
48
|
+
@links_class ||= begin
|
49
|
+
result = Class.new(Sequel::Model(:links)) do
|
50
|
+
def self.name
|
51
|
+
'Link'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
use_current_db(result)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def use_current_db(sequel_model)
|
62
|
+
sequel_model.db = Sequel::Model.db
|
63
|
+
sequel_model
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: n_1_finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrey Glushkov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Finds N+1 queries
|
14
|
+
email: aglushkov@shakuro.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- Readme.md
|
20
|
+
- lib/n_1_finder.rb
|
21
|
+
- lib/n_1_finder/adapters/active_record_adapter.rb
|
22
|
+
- lib/n_1_finder/adapters/base_adapter.rb
|
23
|
+
- lib/n_1_finder/adapters/null_adapter.rb
|
24
|
+
- lib/n_1_finder/adapters/sequel_adapter.rb
|
25
|
+
- lib/n_1_finder/logger.rb
|
26
|
+
- lib/n_1_finder/middleware.rb
|
27
|
+
- lib/n_1_finder/n_1_query.rb
|
28
|
+
- lib/n_1_finder/query.rb
|
29
|
+
- lib/n_1_finder/storage.rb
|
30
|
+
- lib/n_1_finder/version.rb
|
31
|
+
- spec/n_1_finder/adapters/active_record_adapter_spec.rb
|
32
|
+
- spec/n_1_finder/adapters/null_adapter_spec.rb
|
33
|
+
- spec/n_1_finder/adapters/sequel_adapter_spec.rb
|
34
|
+
- spec/n_1_finder/features/active_record_mysql_spec.rb
|
35
|
+
- spec/n_1_finder/features/active_record_postgres_spec.rb
|
36
|
+
- spec/n_1_finder/features/active_record_sqlite_spec.rb
|
37
|
+
- spec/n_1_finder/features/sequel_mysql_spec.rb
|
38
|
+
- spec/n_1_finder/features/sequel_postgres_spec.rb
|
39
|
+
- spec/n_1_finder/features/sequel_sqlite_spec.rb
|
40
|
+
- spec/n_1_finder/logger_spec.rb
|
41
|
+
- spec/n_1_finder/middleware_spec.rb
|
42
|
+
- spec/n_1_finder/n_1_query_spec.rb
|
43
|
+
- spec/n_1_finder/query_spec.rb
|
44
|
+
- spec/n_1_finder/storage_spec.rb
|
45
|
+
- spec/n_1_finder_spec.rb
|
46
|
+
- spec/secrets.yml.example
|
47
|
+
- spec/shared_examples/adapter.rb
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
- spec/support/n_1_helpers.rb
|
50
|
+
- spec/support/orm_helpers.rb
|
51
|
+
- spec/support/test_active_record_migration.rb
|
52
|
+
- spec/support/test_active_record_models.rb
|
53
|
+
- spec/support/test_no_connection_models.rb
|
54
|
+
- spec/support/test_sequel_migration.rb
|
55
|
+
- spec/support/test_sequel_models.rb
|
56
|
+
homepage: https://github.com/aglushkov/n1_finder
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: N+1 Finder
|
80
|
+
test_files: []
|
81
|
+
has_rdoc:
|