ruby-pg-extras 3.0.6 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed716b44ced4653bf0c794ea1690b99cecf460f30dc767a56f328748790d4c0f
4
- data.tar.gz: 3652a5add3cfd162959578af4d840ee494f99311d4b2e48ffbd2f1ca5c078b1e
3
+ metadata.gz: 1b09fa8f29c8e1b0438acf8834d8d51e4ab76b2b8c4c7475e7ac82902d9bc29d
4
+ data.tar.gz: 5a18583d3576f515ea05e0a5d74180c11d811a44d5ecca9d5bad001540f28a98
5
5
  SHA512:
6
- metadata.gz: 3078b1e69e4a36686cc76a2c5326a35b8a61b4751cfe1031df74cda6306ae62fcd07026be2218ca40ac83dd535d0748e608bf00e5e3571aae9de0f1d794d43ff
7
- data.tar.gz: 116e9de1f4a0dc927eef92e6bc88f354c54a5929831d68d7a19c58efbd8085329b0abff6cde1d482757c41d27225191e50bf2852acd9d57637d2306f61568fa7
6
+ metadata.gz: 3a24a0a49e083f081d0d023f4f1b05d3fa867ef5b362f99eb6bc3c711616b857c5f434e5c23ffcc2ba42a0890f562f553694cb45434fa5484402569a827fe1fa
7
+ data.tar.gz: c50dd6d08c4e470a53257af9a7092271a6abeaab308579dc579efcd7df39e9b42031cc01f3d627225fcc73a26bb5c3253a6fe2c94ccc19812fc9671d88936a9b
@@ -18,14 +18,14 @@ module RubyPGExtras
18
18
  end
19
19
 
20
20
  def call
21
- {
22
- table_cache_hit: table_cache_hit,
23
- index_cache_hit: index_cache_hit,
24
- unused_indexes: unused_indexes,
25
- null_indexes: null_indexes,
26
- bloat: bloat,
27
- duplicate_indexes: duplicate_indexes
28
- }.yield_self do |checks|
21
+ [
22
+ :table_cache_hit,
23
+ :index_cache_hit,
24
+ :unused_indexes,
25
+ :null_indexes,
26
+ :bloat,
27
+ :duplicate_indexes
28
+ ].yield_self do |checks|
29
29
  extensions_data = query_module.extensions(in_format: :hash)
30
30
  pg_stats_enabled = extensions_data.find do |el|
31
31
  el.fetch("name") == "pg_stat_statements"
@@ -36,18 +36,16 @@ module RubyPGExtras
36
36
  end.fetch("installed_version", false)
37
37
 
38
38
  if pg_stats_enabled
39
- checks.merge!({
40
- outliers: outliers
41
- })
39
+ checks = checks.concat([:outliers])
42
40
  end
43
41
 
44
42
  if ssl_info_enabled
45
- checks.merge!({
46
- ssl_used: ssl_used
47
- })
43
+ checks = checks.concat([:ssl_used])
48
44
  end
49
45
 
50
46
  checks
47
+ end.map do |check|
48
+ send(check).merge(check_name: check)
51
49
  end
52
50
  end
53
51
 
@@ -9,17 +9,16 @@ module RubyPGExtras
9
9
  end
10
10
 
11
11
  def call(data)
12
- rows = data.sort do |key|
13
- key[1].fetch(:ok) ? 1 : -1
12
+ rows = data.sort do |el|
13
+ p el
14
+ el.fetch(:ok) ? 1 : -1
14
15
  end.map do |el|
15
- key = el[0]
16
- val = el[1]
17
- symbol = val.fetch(:ok) ? "√" : "x"
18
- color = val.fetch(:ok) ? :green : :red
16
+ symbol = el.fetch(:ok) ? "√" : "x"
17
+ color = el.fetch(:ok) ? :green : :red
19
18
 
20
19
  [
21
- colorize("[#{symbol}] - #{key}", color),
22
- colorize(val.fetch(:message), color)
20
+ colorize("[#{symbol}] - #{el.fetch(:check_name)}", color),
21
+ colorize(el.fetch(:message), color)
23
22
  ]
24
23
  end
25
24
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyPGExtras
4
- VERSION = "3.0.6"
4
+ VERSION = "3.1.0"
5
5
  end
@@ -76,6 +76,8 @@ module RubyPGExtras
76
76
  RubyPGExtras::DiagnosePrint.call(data)
77
77
  elsif in_format == :hash
78
78
  data
79
+ elsif in_format == :array
80
+ data.map(&:values)
79
81
  else
80
82
  raise "Invalid 'in_format' argument!"
81
83
  end
@@ -8,20 +8,23 @@ describe RubyPGExtras::DiagnosePrint do
8
8
  end
9
9
 
10
10
  let(:data) do
11
- {
12
- :table_cache_hit => {
11
+ [
12
+ {
13
+ :check_name => :table_cache_hit,
13
14
  :ok => false,
14
15
  :message => "Table hit ratio too low: 0.906977."
15
- },
16
- :index_cache_hit => {
16
+ },
17
+ {
18
+ :check_name => :index_cache_hit,
17
19
  :ok => false,
18
20
  :message => "Index hit ratio is too low: 0.818182."
19
21
  },
20
- :ssl_used => {
22
+ {
23
+ :check_name => :ssl_used,
21
24
  :ok => true,
22
25
  :message => "Database client is using a secure SSL connection."
23
26
  }
24
- }
27
+ ]
25
28
  end
26
29
 
27
30
  describe "call" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.1.0
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-28 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg