activerecord-analyze 0.8.0 → 0.9.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: 125c8ead9447324802fcd4cd6c32c890aecf46c98f6efb3b41ab21d1a51afedd
4
- data.tar.gz: f7314c778b981e2e9ddc89a737d5a24155ed99bd77a9c94a7e350e33b8002d05
3
+ metadata.gz: 054f9f2dad0f0e6a87b82d1722a95889688d3a3b712a4077c0d5892d693ef52f
4
+ data.tar.gz: c08fe69a2a34e6f9b8b51ab40afa24810262e681a9f01109786c8fdcd5bf0285
5
5
  SHA512:
6
- metadata.gz: 9952cb78fcc8076ca6be19f697377b4ded8b2c090ba51affb04e6a6e67a1a83ad5c3900ff4fbf8ef27fa4ad491e881296156ccc79e0424f794f783c6ac050ce3
7
- data.tar.gz: f3a1cf3d8166520a32d1ae83e1c9803500a887abd2ced53d83ddabcace23ada512e2003437d6ed93667645154fa4acf103bfca445b47698790484e8ab02f98bb
6
+ metadata.gz: d6a5ad936771e8a0d6d1fa73c0ac68b2146b7f4d7e6e3c9667def0f7c5450b7ab7109885db4f6590217227e84d821f4d3f976c235dd1f02a6d52d5335db45b04
7
+ data.tar.gz: c2e987200963f0acf13eb734a6ae1bdd0212bcc68bae3aad1274fe8c0cd27f0cdd28d714ade1d1f15e76dc6b7d7d31fc83340ad80c541874e445ac4807776934
data/README.md CHANGED
@@ -23,13 +23,13 @@ gem 'activerecord-analyze'
23
23
  The `analyze` method supports the following EXPLAIN query options ([PostgreSQL docs reference](https://www.postgresql.org/docs/12/sql-explain.html)):
24
24
 
25
25
  ```
26
- BUFFERS [ boolean ]
27
- VERBOSE [ boolean ]
28
- COSTS [ boolean ]
29
- SETTINGS [ boolean ]
30
- TIMING [ boolean ]
31
- SUMMARY [ boolean ]
32
- FORMAT { TEXT | XML | JSON | YAML }
26
+ buffers: [ boolean ]
27
+ verbose: [ boolean ]
28
+ costs: [ boolean ]
29
+ settings: [ boolean ]
30
+ timing: [ boolean ]
31
+ summary: [ boolean ]
32
+ format: { :text | :json | :xml | :yaml | :pretty_json }
33
33
  ```
34
34
 
35
35
  You can execute it like that:
@@ -37,7 +37,7 @@ You can execute it like that:
37
37
  ```ruby
38
38
 
39
39
  puts User.all.analyze(
40
- format: :pretty, # :pretty format option generates a formatted JSON output
40
+ format: :pretty_json, # :pretty_json format option generates a formatted JSON output
41
41
  verbose: true,
42
42
  costs: true,
43
43
  settings: true,
@@ -9,7 +9,7 @@ module ActiveRecord
9
9
  "FORMAT JSON,"
10
10
  when :hash
11
11
  "FORMAT JSON,"
12
- when :pretty
12
+ when :pretty_json
13
13
  "FORMAT JSON,"
14
14
  when :yaml
15
15
  "FORMAT YAML,"
@@ -68,7 +68,7 @@ module ActiveRecord
68
68
  class Relation
69
69
  def analyze(opts = {})
70
70
  res = exec_analyze(collecting_queries_for_explain { exec_queries }, opts)
71
- if [:json, :hash, :pretty].include?(opts[:format])
71
+ if [:json, :hash, :pretty_json].include?(opts[:format])
72
72
  start = res.index("[\n")
73
73
  finish = res.rindex("]")
74
74
  raw_json = res.slice(start, finish - start + 1)
@@ -77,7 +77,7 @@ module ActiveRecord
77
77
  JSON.parse(raw_json).to_json
78
78
  elsif opts[:format] == :hash
79
79
  JSON.parse(raw_json)
80
- elsif opts[:format] == :pretty
80
+ elsif opts[:format] == :pretty_json
81
81
  JSON.pretty_generate(JSON.parse(raw_json))
82
82
  end
83
83
  else
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordAnalyze
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/spec/main_spec.rb CHANGED
@@ -43,7 +43,7 @@ describe "ActiveRecord analyze" do
43
43
 
44
44
  describe "format pretty" do
45
45
  it "works" do
46
- result = User.all.analyze(format: :pretty)
46
+ result = User.all.analyze(format: :pretty_json)
47
47
  expect(JSON.parse(result)[0].keys.sort).to eq [
48
48
  "Execution Time", "Plan", "Planning Time", "Triggers"
49
49
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-analyze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb