rails-pg-extras-web 1.5.3 → 1.6.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: d0867a93537ef7b75064a408a632ab466f1ff2e8163de3b6dc604b3bcaad9bbe
4
- data.tar.gz: 2ad9ef98329c15accb2e02974fed7101611b95cae8dbf77bef77be9caa9ef6a1
3
+ metadata.gz: c7f43ce0a38a6e61ba4c9424cd92614afd7f6609436d9da8aa0365365ad08a87
4
+ data.tar.gz: e0ffa21d94bc8c12069c081d746410b954d9dd56b2e88809b36fd456e94bca30
5
5
  SHA512:
6
- metadata.gz: e1cbdfad662c7da11b61d4675cab7eaee7c5498bda223771fa634cb5b8498da5f2bfe7c378fb370363d22c3404367e4dc1c63f8debca87ff70d81df2a6ce8dd6
7
- data.tar.gz: a1331dbb06b9017fd36b3776f543a91fef069b62722cb31f3d229a2c6a05d8f6ba3b5aff6c1b45587de3cceebffd71dac4c75ee3be871fdefe437e1ddb143a45
6
+ metadata.gz: 55039e4b67cc04e64545ab07092bf135f9844ae84414d1a7688957fdcad0124918f538b4f3f020e133b7fedabfe86e4b3b5682654887794429c6d9c75ee99834
7
+ data.tar.gz: 368e5bcda5b27669152df55c5fec5940a7575bd1557628af8d206cd2f4221700eedf91818dfdad08dd7262bd37866eab47be7d018559eec368cb91df9158dbc4
@@ -1,7 +1,12 @@
1
1
  module RailsPgExtrasWeb
2
2
  class QueriesController < ApplicationController
3
+ REQUIRED_EXTENSIONS = {
4
+ pg_stat_statements: %i[calls outliers],
5
+ pg_buffercache: %i[buffercache_stats buffercache_usage]
6
+ }
7
+
3
8
  before_action :load_queries
4
- helper_method :pg_stats_statements_enabled?
9
+ helper_method :unavailable_extensions
5
10
 
6
11
  def index
7
12
  @query_name = params[:query_name]&.to_sym.presence_in(@all_queries.keys)
@@ -26,11 +31,21 @@ module RailsPgExtrasWeb
26
31
  end
27
32
 
28
33
  def query_disabled?(query_name)
29
- query_name.in?([:calls, :outliers]) && !pg_stats_statements_enabled?
34
+ case query_name
35
+ when :calls, :outliers
36
+ unavailable_extensions.key?(:pg_stat_statements)
37
+ when :buffercache_stats, :buffercache_usage
38
+ unavailable_extensions.key?(:pg_buffercache)
39
+ else
40
+ false
41
+ end
30
42
  end
31
43
 
32
- def pg_stats_statements_enabled?
33
- ActiveRecord::Base.connection.extensions.include?("pg_stat_statements")
44
+ def unavailable_extensions
45
+ return @unavailable_extensions if defined?(@unavailable_extensions)
46
+
47
+ extensions = ActiveRecord::Base.connection.extensions
48
+ @unavailable_extensions = REQUIRED_EXTENSIONS.select { |extension, _| !extensions.include?(extension.to_s) }
34
49
  end
35
50
  end
36
51
  end
@@ -1,12 +1,14 @@
1
- <% unless pg_stats_statements_enabled? %>
2
- <span style='color: red'>
3
- WARNING: <b><u>outliers</u></b>, <b><u>calls</u></b> require extension: <b>pg_stat_statements</b>
4
- </span>
1
+ <% if unavailable_extensions.any? && !@result %>
2
+ <% unavailable_extensions.each do |extension, queries| %>
3
+ <span style='color: orange'>
4
+ WARNING: Queries <%= queries.map { |q| "<b><u>#{q}</u></b>" }.join(", ").html_safe %> require extension: <b><%= extension %></b>
5
+ </span>
5
6
 
6
- <h4>Rails</h4>
7
- <pre style='background-color: #e2e2e2; padding: 10px'>ActiveRecord::Base.connection.enable_extension "pg_stat_statements"</pre>
8
- <h4>SQL</h4>
9
- <pre style='background-color: #e2e2e2; padding: 10px'>CREATE EXTENSION pg_stat_statements</pre>
7
+ <h4>Rails</h4>
8
+ <pre style='background-color: #e2e2e2; padding: 10px'>ActiveRecord::Base.connection.enable_extension "<%= extension %>"</pre>
9
+ <h4>SQL</h4>
10
+ <pre style='background-color: #e2e2e2; padding: 10px'>CREATE EXTENSION <%= extension %></pre>
11
+ <% end %>
10
12
  <% end %>
11
13
 
12
14
  <% if @error %>
@@ -1,3 +1,3 @@
1
1
  module RailsPgExtrasWeb
2
- VERSION = '1.5.3'
2
+ VERSION = '1.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Mazur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.5.0
33
+ version: 1.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.5.0
40
+ version: 1.6.0
41
41
  description:
42
42
  email:
43
43
  - tomasz.mazur@hey.com
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.1.4
78
+ rubygems_version: 3.1.6
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Web UI for rails-pg-extras