shiba 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 1976edef35324cc1d8c62239938ef8fa2ceaa247
4
- data.tar.gz: 26425a11975b434ca85f100e1608ac79812b2b8d
3
+ metadata.gz: ad898fa0f36457fbd570698c276b567f6f09f1a2
4
+ data.tar.gz: '028e8a99dff1f8c843bcb222151a0c100f0ebbe1'
5
5
  SHA512:
6
- metadata.gz: 728df84438f0eb7d40dc3c05a718ee913dafc6a7a9275859f489875e91ccf6ba73ddb5431eb61650f7e4ddf8be9b39f3f52dbfec3a8f45bfe8b893429bb77fdb
7
- data.tar.gz: 113296428f8336a3a21e639415badf893bd0ed178c17b536aa282e4575ecd6e6b2dc385bae336ca88ce5ceafe216e3da2c2943cb615b969294d0e449779947a7
6
+ metadata.gz: 716210a01a6fded73a217b03992371c4d8dcff472f1a69a6195cb53e1dfb122b8c43c512fa7f4ef30bbf776ee8eff3fcabe356bb3e5f4967cec5a4383ec1675a
7
+ data.tar.gz: 4f7434ec7c78fa7134947ecfe90d9706e4cb22e800eb8036b03216522dee96c8d42e2a33409c5b40e9f4fbb478e48bf6a5e127c3fe0c05284819bd9d87f392ea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shiba (0.2.2)
4
+ shiba (0.2.3)
5
5
  activesupport
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -14,19 +14,21 @@ By default, it will pretty much only detect queries that miss indexes. As it's f
14
14
  Install using bundler. Note: this gem is not designed to be run on production.
15
15
 
16
16
  ```ruby
17
- gem 'shiba', :group => :test, :require => true
17
+ # Gemfile
18
+ gem 'shiba', :group => :test
18
19
  ```
19
20
 
20
- If this doesn't magically work, you can manually configure it using an initializer:
21
+ If your application lazy loads gems, you will to manually require it.
21
22
 
22
23
  ```ruby
23
- require 'shiba/activerecord_integration'
24
- Shiba::ActiveRecordIntegration.install!
24
+ # config/environments/test.rb or test/test_helper.rb
25
+ require 'shiba/setup'
25
26
  ```
26
27
 
27
28
  ## Usage
28
29
 
29
30
  A report will only be generated when problem queries are detected.
31
+ To verify shiba is actually running, you can run your tests with SHIBA_DEBUG=true.
30
32
 
31
33
  ```ruby
32
34
  # Install
@@ -35,11 +37,17 @@ bundle
35
37
  # Run some tests using to generate a SQL report
36
38
  rake test:functional
37
39
  rails test test/controllers/users_controller_test.rb
40
+ SHIBA_DEBUG=true ruby test/controllers/users_controller_test.rb
38
41
 
39
42
  # 1 problematic query detected
40
43
  # Report available at /tmp/shiba-explain.log-1550099512
41
44
  ```
42
45
 
46
+ ### Screenshot
47
+ `open /tmp/shiba-explain.log-1550099512`
48
+ ![screenshot](/data/screenshot.png?raw=true)
49
+
50
+
43
51
  ## Typical query problems
44
52
 
45
53
  Here are some typical query problems Shiba can detect. We'll assume the following schema:
@@ -85,7 +93,7 @@ With more data, Shiba can help detect this issue when it appears in a pull reque
85
93
 
86
94
  ## Going beyond table scans
87
95
 
88
- For smarter analysis, Shiba requires general statistics about production data, such as the number of rows in a table and how unique columns are.
96
+ Without more information, Shiba acts as a simple missed index detector. To catch other problems that can bring down production (or at least cause some performance issues), Shiba requires general statistics about production data, such as the number of rows in a table and how unique columns are.
89
97
 
90
98
  This information can be obtained by running the bin/dump_stats command in production.
91
99
 
@@ -100,7 +108,9 @@ scp production:~/shiba_index.yml RAILS_PROJECT/config
100
108
  ```
101
109
 
102
110
  The stats file will look similar to the following:
103
-
111
+ ```console
112
+ local$ head <rails_project>/config/shiba_index.yml
113
+ ```
104
114
  ```yaml
105
115
  users:
106
116
  count: 10000
@@ -0,0 +1,3 @@
1
+ require 'shiba'
2
+ require 'shiba/activerecord_integration'
3
+ Shiba::ActiveRecordIntegration.install!
data/lib/shiba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shiba
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/web/results.html.erb CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  Query.prototype = {
45
45
  hasTag: function(tag) {
46
- this.tags.includes(tag);
46
+ return this.tags.includes(tag);
47
47
  },
48
48
  splitSQL: function() {
49
49
  this.sqlFragments = this.sql.match(/(SELECT\s)(.*?)(\s+FROM .*)/i);
@@ -175,7 +175,8 @@
175
175
  <div class="row">
176
176
  <div v-if="hasFuzzed" class="alert alert-warning" role="alert">
177
177
  This query analysis was generated using estimated table sizes.
178
- <a href="https://github.com/burrito-brothers/shiba/blob/master/README.md#going-beyond-table-scans">Find out how to get a more accurate analysis by feeding Shiba index stats</a>
178
+ To improve these results and find other problem queries beyond missing indexes, we'll need more stats.<br/>
179
+ <a target="_blank" href="https://github.com/burrito-brothers/shiba/blob/master/README.md#going-beyond-table-scans">Find out how to get a more accurate analysis by feeding Shiba index stats</a>
179
180
  </div>
180
181
 
181
182
  <div class="col-12">We found {{ queries.length }} queries that deserve your attention: </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
@@ -102,6 +102,7 @@ files:
102
102
  - lib/shiba/output/tags.yaml
103
103
  - lib/shiba/query.rb
104
104
  - lib/shiba/query_watcher.rb
105
+ - lib/shiba/setup.rb
105
106
  - lib/shiba/table_stats.rb
106
107
  - lib/shiba/version.rb
107
108
  - shiba.gemspec