rails-pg-extras 2.3.0 → 3.0.6

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: 67b102fb8ff0b2dc05c7bf14662b8a4359808356f0f36e55ec6ab9012824a936
4
- data.tar.gz: 41c9c07be416ccf5a3558d2488a5c242e14e594864935545693940b8cf40875d
3
+ metadata.gz: 7e964bd79450c28fff1d34129197b25e09b5dad8a3a6a355a1370ba7de725a2e
4
+ data.tar.gz: bf67d3b1929cd8495fce8cc9b4f867e8367564b26c118d9147af7dfb32e58115
5
5
  SHA512:
6
- metadata.gz: 8208f2581593a9fff622add53dc6d3e8051abf570ce404f2cc48df9e6b5793635f8679e489b457b319951926a81803304d6a3b464114c989722f6917bf9ff121
7
- data.tar.gz: aef18c1ccdcff519549efae8c4dfb379f8ef4eb20662e2948af4b54ad04e46c316c7cc10164415793bfd8364c70785eab7b4f115d20d38f830993441830371d1
6
+ metadata.gz: d82267114ee40e3ed8d39b2d12427f101a98a9c98f0505ca6ae84a60637e98e676193ba9e21727f1989bb32b95e41ac8414ab6dd6b7084d0f3bba381a4889901
7
+ data.tar.gz: 32a5bdee701af1f3407a092016a36360000d459ac447e770507c6ec723de072574f52270862f22c8d129bcb055402631121b83c55b54058347e05b098080ee84
data/.circleci/config.yml CHANGED
@@ -31,7 +31,8 @@ jobs:
31
31
  - checkout
32
32
  - run: gem update --system
33
33
  - run: gem install bundler
34
- - run: bundle install --path vendor/bundle
34
+ - run: bundle config set --local path 'vendor/bundle'
35
+ - run: bundle install
35
36
  - run: sudo apt-get update --allow-releaseinfo-change
36
37
  - run: sudo apt install postgresql-client
37
38
  - run: dockerize -wait tcp://postgres11:5432 -timeout 1m
data/README.md CHANGED
@@ -32,7 +32,7 @@ In your Gemfile
32
32
  gem "rails-pg-extras"
33
33
  ```
34
34
 
35
- Some of the queries (e.g., `calls` and `outliers`) require [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension enabled.
35
+ `calls` and `outliers` queries require [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension.
36
36
 
37
37
  You can check if it is enabled in your database by running:
38
38
 
@@ -45,6 +45,12 @@ You should see the similar line in the output:
45
45
  | pg_stat_statements | 1.7 | 1.7 | track execution statistics of all SQL statements executed |
46
46
  ```
47
47
 
48
+ `ssl_used` requires `sslinfo` extension, and `buffercache_usage`/`buffercache_usage` queries need `pg_buffercache`. You can enable them all by running:
49
+
50
+ ```ruby
51
+ RailsPGExtras.add_extensions
52
+ ```
53
+
48
54
  ## Usage
49
55
 
50
56
  Each command can be used as a rake task, or a directly from the Ruby code.
@@ -91,6 +97,18 @@ RailsPGExtras.long_running_queries(args: { threshold: "200 milliseconds" })
91
97
 
92
98
  ```
93
99
 
100
+ ## Diagnose report
101
+
102
+ The simplest way to start using pg-extras is to execute a `diagnose` method. It runs a set of checks and prints out a report highlighting areas that may require additional investigation:
103
+
104
+ ```ruby
105
+ RailsPGExtras.diagnose
106
+ ```
107
+
108
+ ![Diagnose report](https://github.com/pawurb/rails-pg-extras/raw/master/rails-pg-extras-diagnose.png)
109
+
110
+ Keep reading to learn about methods that `diagnose` uses under the hood.
111
+
94
112
  ## Available methods
95
113
 
96
114
  ### `cache_hit`
@@ -398,7 +416,7 @@ This command displays the total size of each table and materialized view in the
398
416
  ### `unused_indexes`
399
417
 
400
418
  ```ruby
401
- RailsPGExtras.unused_indexes(args: { min_scans: 20 })
419
+ RailsPGExtras.unused_indexes(args: { max_scans: 20 })
402
420
 
403
421
  $ rake pg_extras:unused_indexes
404
422
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsPGExtras
4
+ class DiagnoseData < RubyPGExtras::DiagnoseData
5
+
6
+ private
7
+
8
+ def query_module
9
+ RailsPGExtras
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsPGExtras
4
+ class DiagnosePrint < RubyPGExtras::DiagnosePrint
5
+
6
+ private
7
+
8
+ def title
9
+ "rails-pg-extras - diagnose report"
10
+ end
11
+ end
12
+ end
@@ -19,4 +19,9 @@ namespace :pg_extras do
19
19
  RailsPGExtras.public_send(query_name)
20
20
  end
21
21
  end
22
+
23
+ desc "Generate a PostgreSQL healthcheck report"
24
+ task diagnose: :establish_connection do
25
+ RailsPGExtras.diagnose
26
+ end
22
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPGExtras
4
- VERSION = "2.3.0"
4
+ VERSION = "3.0.6"
5
5
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'terminal-table'
4
4
  require 'ruby-pg-extras'
5
+ require 'rails-pg-extras/diagnose_data'
6
+ require 'rails-pg-extras/diagnose_print'
5
7
 
6
8
  module RailsPGExtras
7
9
  QUERIES = RubyPGExtras::QUERIES
@@ -44,6 +46,18 @@ module RailsPGExtras
44
46
  )
45
47
  end
46
48
 
49
+ def self.diagnose(in_format: :display_table)
50
+ data = RailsPGExtras::DiagnoseData.call
51
+
52
+ if in_format == :display_table
53
+ RailsPGExtras::DiagnosePrint.call(data)
54
+ elsif in_format == :hash
55
+ data
56
+ else
57
+ raise "Invalid 'in_format' argument!"
58
+ end
59
+ end
60
+
47
61
  def self.connection
48
62
  ActiveRecord::Base.connection
49
63
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-pg-extras
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 3.0.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.0
26
+ version: 3.0.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -83,9 +83,12 @@ files:
83
83
  - Rakefile
84
84
  - docker-compose.yml.sample
85
85
  - lib/rails-pg-extras.rb
86
+ - lib/rails-pg-extras/diagnose_data.rb
87
+ - lib/rails-pg-extras/diagnose_print.rb
86
88
  - lib/rails-pg-extras/railtie.rb
87
89
  - lib/rails-pg-extras/tasks/all.rake
88
90
  - lib/rails-pg-extras/version.rb
91
+ - rails-pg-extras-diagnose.png
89
92
  - rails-pg-extras-web.png
90
93
  - rails-pg-extras.gemspec
91
94
  - spec/smoke_spec.rb