traceindex 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32652626eba05019e1228a39ca642acb95940610c66cd3dd1c316baf0e8e3fcf
4
- data.tar.gz: 234f0ad667a6af183f33d83b235648471b6708555e2136ff60319a8f742ad0de
3
+ metadata.gz: b0a76e873f9bb112b3cd1f98613af8aa41754e426943e22fef117254b1a1309c
4
+ data.tar.gz: 98cd2a6ab6c7cd985648edc1310cad7197e444b7bb497e6fb4c698fb958a9d95
5
5
  SHA512:
6
- metadata.gz: db4abce12669dbd750471345fef3c4a1d8b0e27b0403f41e06cbd2b893158df290eee2010087f0056618c361fc44689e407a1893e1263328e14be077a7de1fdb
7
- data.tar.gz: 3f731c2f5aaac5ead38371cb22dde681cb473325840858319cb3dad955f4f3dd25312339fbd4dc929caf99f7f8ca56f2fce17bf7613bd5eeb6ffad07ac188b24
6
+ metadata.gz: b7b05e1ccfd3f5a79adc80bc3b0412b19dc8ee47b725fa8f9d1ffe5a8c8f9fa4400d05a88465dd2fdc0c32fbe09c9e5d437697a02a72c5caaf3b93ecb1208335
7
+ data.tar.gz: ed7118e1fd8b2aa65da7422f04963bfeacab40d516d64f79f683b14888be31637b641ad6891866d638f38a64e91e70cdc5f991e2aa683f8410306dd8a98f1442
data/.circleci/config.yml CHANGED
@@ -11,7 +11,6 @@ executors:
11
11
  DB_HOST: '127.0.0.1'
12
12
  - image: circleci/mysql:8-ram
13
13
  environment:
14
- MYSQL_USER: root
15
14
  MYSQL_ROOT_PASSWORD: root
16
15
  MYSQL_DATABASE: traceindex_test
17
16
  command: [--default-authentication-plugin=mysql_native_password]
data/README.md CHANGED
@@ -40,13 +40,14 @@ If you want the rake task to ignore foreign_keys.
40
40
  Create a .traceindex.yaml or .traceindex.yml file in your root directory.
41
41
 
42
42
  ```yaml
43
+ ignore_tables:
44
+ - action_mailbox_inbound_emails
45
+ - action_text_rich_texts
46
+ - active_storage_attachments
47
+ - active_storage_blobs
48
+ - active_storage_variant_records
43
49
  ignore_columns:
44
50
  - users.created_user_id
45
- ignore_models:
46
- - ActiveStorage::Blob
47
- - ActiveStorage::Attachment
48
- - ActionText::RichText
49
- - ActionMailbox::InboundEmail
50
51
  ignore_foreign_keys:
51
52
  - users.created_user_id
52
53
  ```
data/lib/traceindex.rb CHANGED
@@ -9,21 +9,10 @@ class Traceindex
9
9
 
10
10
  def initialize(app)
11
11
  @app = app
12
- @ignore_models = []
13
- @ignore_columns = []
14
- @ignore_foreign_keys = []
15
-
16
- (config["ignore_models"] || []).each do |ignored_model|
17
- @ignore_models << ignored_model
18
- end
19
-
20
- (config["ignore_columns"] || []).each do |ignored_column|
21
- @ignore_columns << ignored_column
22
- end
23
-
24
- (config["ignore_foreign_keys"] || []).each do |ignored_column|
25
- @ignore_foreign_keys << ignored_column
26
- end
12
+ @ignore_models = (config["ignore_models"] || [])
13
+ @ignore_columns = (config["ignore_columns"] || [])
14
+ @ignore_foreign_keys = (config["ignore_foreign_keys"] || [])
15
+ @ignore_tables = (config["ignore_tables"] || [])
27
16
  end
28
17
 
29
18
  def missing_index_column_names
@@ -80,7 +69,7 @@ class Traceindex
80
69
 
81
70
  @app.eager_load!
82
71
  @models ||= ActiveRecord::Base.descendants.reject(&:abstract_class).reject do |model|
83
- @ignore_models.include?(model.name)
72
+ @ignore_models.include?(model.name) || @ignore_tables.include?(model.table_name)
84
73
  end
85
74
  end
86
75
  end
@@ -42,6 +42,19 @@ describe Traceindex do
42
42
  end
43
43
  end
44
44
 
45
+ context 'If you have a configuration file(ignore_tables)' do
46
+ before do
47
+ File.open '.traceindex.yml', 'w' do |file|
48
+ file.puts 'ignore_tables:'
49
+ file.puts ' - users'
50
+ end
51
+ end
52
+
53
+ it 'missing index not found.' do
54
+ expect(traceindex.missing_index_column_names).to eq([])
55
+ end
56
+ end
57
+
45
58
  context 'If you have a configuration file(ignore_foreign_keys)' do
46
59
  before do
47
60
  File.open '.traceindex.yml', 'w' do |file|
data/traceindex.gemspec CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path('lib', __dir__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'traceindex'
5
- s.version = '0.0.2'
5
+ s.version = '0.1.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ['Akira Kusumoto']
8
8
  s.email = ['akirakusumo10@gmail.com']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traceindex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Kusumoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -91,7 +91,7 @@ homepage: https://github.com/bluerabbit/traceindex
91
91
  licenses:
92
92
  - MIT
93
93
  metadata: {}
94
- post_install_message:
94
+ post_install_message:
95
95
  rdoc_options: []
96
96
  require_paths:
97
97
  - lib
@@ -106,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  requirements: []
109
- rubygems_version: 3.0.3
110
- signing_key:
109
+ rubygems_version: 3.3.7
110
+ signing_key:
111
111
  specification_version: 4
112
112
  summary: A Rake task that helps you find the missing indexes for your Rails app
113
113
  test_files: