pghero 3.6.0 → 3.6.1

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: 725af86da804f9f7869d727483cdc077de020c77cf5d364abecb943db6b2e7e9
4
- data.tar.gz: 0e15c553a23d7288711f1b16e619ffff6cc38bbb26a1539477ed6f7eb11e2e6b
3
+ metadata.gz: a7dc52d94fbdd96a3efcef37d4739855cb5e9ab0da76c53d345141c3a0f28021
4
+ data.tar.gz: 6e1640fb5ff339f5d0523d7acebb4655c0426b877a2a6545e53fb0af386769da
5
5
  SHA512:
6
- metadata.gz: 435b20217db356ac5d28450d92a5f96d44fef1ea3a2b909f8d9c713393f3dee3f9fea9e2be6737320280d1663dbab20fb19165d01b70d4842ea6f32978bb0465
7
- data.tar.gz: edab3df03d6a47681f9fff134d0fc5fa070fa5262d74092948aa76ade0dbba2977ef885120894ec0cb4a1e007b46454373c529239cb4fc1f002b2d8702dba17e
6
+ metadata.gz: d1ad10cfe918c2ab278af7aa96fcf5b08ccce3b6454f9630d7a628c9be0d54d0d3f5110d9ec4ab9248ee42556bba66166347412d284074820ed35069292ce72f
7
+ data.tar.gz: 4a7cc686fb1074c827a21e5b9ee8ce5a82119926b05e9ea8cdacd31759765932767df2638bd0790543e5f252507c97863c9572be7112be22244927396d93dce7
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ ## 3.6.1 (2024-10-14)
2
+
3
+ - Fixed error when Propshaft is installed but not used
4
+
1
5
  ## 3.6.0 (2024-07-10)
2
6
 
3
7
  - Improved CSP support
8
+ - Dropped support for Linux packages for Ubuntu 18.04, CentOS 7, and SLES 12
4
9
  - Dropped support for Ruby < 3.1 and Rails < 6.1
5
10
 
6
11
  ## 3.5.0 (2024-05-21)
@@ -5,7 +5,7 @@
5
5
 
6
6
  <meta charset="utf-8" />
7
7
  <%= favicon_link_tag "pghero/favicon.png" %>
8
- <% if defined?(Propshaft::Railtie) %>
8
+ <% if defined?(Propshaft::Railtie) && Rails.application.assets.is_a?(Propshaft::Assembly) %>
9
9
  <%= stylesheet_link_tag "pghero/nouislider", "pghero/arduino-light", "pghero/application" %>
10
10
  <%= javascript_include_tag "pghero/jquery", "pghero/nouislider", "pghero/Chart.bundle", "pghero/chartkick", "pghero/highlight.min", "pghero/application", nonce: true %>
11
11
  <% else %>
@@ -126,7 +126,7 @@ module PgHero
126
126
  # rough check for Postgres adapter
127
127
  # keep this message generic so it's useful
128
128
  # when empty url set in Docker image pghero.yml
129
- unless @connection_model.connection.adapter_name.match?(/postg/i)
129
+ unless @connection_model.connection_db_config.adapter.to_s.match?(/postg/i)
130
130
  raise Error, "Invalid connection URL"
131
131
  end
132
132
  @adapter_checked = true
data/lib/pghero/engine.rb CHANGED
@@ -4,8 +4,8 @@ module PgHero
4
4
 
5
5
  initializer "pghero", group: :all do |app|
6
6
  # check if Rails api mode
7
- if app.config.respond_to?(:assets)
8
- if defined?(Sprockets) && Sprockets::VERSION.to_i >= 4
7
+ if app.config.respond_to?(:assets) && defined?(Sprockets)
8
+ if Sprockets::VERSION.to_i >= 4
9
9
  app.config.assets.precompile << "pghero/application.js"
10
10
  app.config.assets.precompile << "pghero/application.css"
11
11
  app.config.assets.precompile << "pghero/favicon.png"
@@ -31,13 +31,18 @@ module PgHero
31
31
  end
32
32
 
33
33
  def quote_ident(value)
34
- connection.quote_column_name(value)
34
+ with_connection { |c| c.quote_column_name(value) }
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- def select_all(sql, conn: nil, query_columns: [])
40
- conn ||= connection
39
+ def select_all(sql, stats: false, query_columns: [])
40
+ with_connection(stats: stats) do |conn|
41
+ select_all_leased(sql, conn: conn, query_columns: query_columns)
42
+ end
43
+ end
44
+
45
+ def select_all_leased(sql, conn:, query_columns:)
41
46
  # squish for logs
42
47
  retries = 0
43
48
  begin
@@ -81,7 +86,7 @@ module PgHero
81
86
  end
82
87
 
83
88
  def select_all_stats(sql, **options)
84
- select_all(sql, **options, conn: stats_connection)
89
+ select_all(sql, **options, stats: true)
85
90
  end
86
91
 
87
92
  def select_all_size(sql)
@@ -92,24 +97,17 @@ module PgHero
92
97
  result
93
98
  end
94
99
 
95
- def select_one(sql, conn: nil)
96
- select_all(sql, conn: conn).first.values.first
97
- end
98
-
99
- def select_one_stats(sql)
100
- select_one(sql, conn: stats_connection)
100
+ def select_one(sql)
101
+ select_all(sql).first.values.first
101
102
  end
102
103
 
103
104
  def execute(sql)
104
- connection.execute(add_source(sql))
105
- end
106
-
107
- def connection
108
- connection_model.connection
105
+ with_connection { |c| c.execute(add_source(sql)) }
109
106
  end
110
107
 
111
- def stats_connection
112
- ::PgHero::Stats.connection
108
+ def with_connection(stats: false, &block)
109
+ model = stats ? ::PgHero::Stats : connection_model
110
+ model.connection_pool.with_connection(&block)
113
111
  end
114
112
 
115
113
  def squish(str)
@@ -121,15 +119,15 @@ module PgHero
121
119
  end
122
120
 
123
121
  def quote(value)
124
- connection.quote(value)
122
+ with_connection { |c| c.quote(value) }
125
123
  end
126
124
 
127
125
  def quote_table_name(value)
128
- connection.quote_table_name(value)
126
+ with_connection { |c| c.quote_table_name(value) }
129
127
  end
130
128
 
131
129
  def quote_column_name(value)
132
- connection.quote_column_name(value)
130
+ with_connection { |c| c.quote_column_name(value) }
133
131
  end
134
132
 
135
133
  def unquote(part)
@@ -150,7 +148,7 @@ module PgHero
150
148
  end
151
149
 
152
150
  def table_exists?(table)
153
- stats_connection.table_exists?(table)
151
+ with_connection(stats: true) { |c| c.table_exists?(table) }
154
152
  end
155
153
  end
156
154
  end
@@ -79,7 +79,9 @@ module PgHero
79
79
  suggested_indexes.each do |index|
80
80
  p index
81
81
  if create
82
- connection.execute("CREATE INDEX CONCURRENTLY ON #{quote_table_name(index[:table])} (#{index[:columns].map { |c| quote_column_name(c) }.join(",")})")
82
+ with_connection do |connection|
83
+ connection.execute("CREATE INDEX CONCURRENTLY ON #{quote_table_name(index[:table])} (#{index[:columns].map { |c| quote_column_name(c) }.join(",")})")
84
+ end
83
85
  end
84
86
  end
85
87
  end
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "3.6.0"
2
+ VERSION = "3.6.1"
3
3
  end
data/lib/pghero.rb CHANGED
@@ -64,7 +64,7 @@ module PgHero
64
64
  :query_stats_available?, :query_stats_enabled?, :query_stats_extension_enabled?, :query_stats_readable?,
65
65
  :rds_stats, :read_iops_stats, :aws_region, :relation_sizes, :replica?, :replication_lag, :replication_lag_stats,
66
66
  :reset_query_stats, :reset_stats, :running_queries, :aws_secret_access_key, :sequence_danger, :sequences, :settings,
67
- :slow_queries, :space_growth, :ssl_used?, :stats_connection, :suggested_indexes, :suggested_indexes_by_query,
67
+ :slow_queries, :space_growth, :ssl_used?, :suggested_indexes, :suggested_indexes_by_query,
68
68
  :suggested_indexes_enabled?, :system_stats_enabled?, :table_caching, :table_hit_rate, :table_stats,
69
69
  :total_connections, :transaction_id_danger, :unused_indexes, :unused_tables, :write_iops_stats
70
70
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pghero
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.5.11
127
+ rubygems_version: 3.5.16
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: A performance dashboard for Postgres