rails-pg-extras 5.3.1 → 5.4.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 +4 -4
- data/.github/workflows/ci.yml +1 -2
- data/Gemfile +1 -1
- data/README.md +6 -2
- data/Rakefile +2 -3
- data/app/controllers/rails_pg_extras/web/application_controller.rb +4 -4
- data/app/controllers/rails_pg_extras/web/queries_controller.rb +1 -1
- data/app/views/rails_pg_extras/web/queries/_diagnose.html.erb +1 -1
- data/app/views/rails_pg_extras/web/queries/_unavailable_extensions_warning.html.erb +9 -9
- data/app/views/rails_pg_extras/web/queries/index.html.erb +10 -12
- data/app/views/rails_pg_extras/web/queries/show.html.erb +12 -13
- data/app/views/rails_pg_extras/web/shared/_queries_selector.html.erb +4 -5
- data/config/routes.rb +3 -3
- data/lib/rails-pg-extras.rb +24 -25
- data/lib/rails_pg_extras/diagnose_data.rb +0 -1
- data/lib/rails_pg_extras/diagnose_print.rb +0 -1
- data/lib/rails_pg_extras/railtie.rb +1 -1
- data/lib/rails_pg_extras/tasks/all.rake +1 -1
- data/lib/rails_pg_extras/version.rb +1 -1
- data/lib/rails_pg_extras/web/engine.rb +1 -1
- data/rails-pg-extras.gemspec +13 -12
- data/spec/smoke_spec.rb +5 -5
- data/spec/spec_helper.rb +14 -14
- metadata +19 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61f5b6a2a631c8d8099b67c1c28334cbc3ce64dddd53e3977877265362a04d71
|
|
4
|
+
data.tar.gz: ec8b4100e944153f9be8ddb8d9286441bf449f3262392129615dd0df28212a0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af548830ba4e66131a55a093bbc14f23907c0b9ad6335322ce6d20dedf76872f05cc40afa00eef996943044e9cc0b0b93a869b2859011e1729eb9b63f1cff311
|
|
7
|
+
data.tar.gz: 2bcf26a2ad56ff96715a15abd276d990a312e8d1d7d643c45f315ae8629e987534f91bc18be82d9cefe7e6b08eab4fb631046dec2c38987e5ed524d5c5a77ab7
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -57,8 +57,7 @@ jobs:
|
|
|
57
57
|
ruby-version: ${{ matrix.ruby-version }}
|
|
58
58
|
- name: Setup dependencies
|
|
59
59
|
run: |
|
|
60
|
-
gem
|
|
61
|
-
gem install bundler
|
|
60
|
+
gem install bundler -v 2.4.22
|
|
62
61
|
sudo apt-get update --allow-releaseinfo-change
|
|
63
62
|
sudo apt install postgresql-client
|
|
64
63
|
sudo apt install libpq-dev
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Included rake tasks and Ruby methods can be used to obtain information about a P
|
|
|
6
6
|
|
|
7
7
|
You can read this blog post for detailed step by step tutorial on how to [optimize PostgreSQL using PG Extras library](https://pawelurbanek.com/postgresql-fix-performance).
|
|
8
8
|
|
|
9
|
-
**Shameless plug:** rails-pg-extras is one of the tools that I use when conducting Rails performance audits
|
|
9
|
+
**Shameless plug:** rails-pg-extras is just one of the tools that I use when conducting [Rails performance audits](https://pawelurbanek.com/optimize-rails-performance). Check out my offer if you need help with optimizing your application.
|
|
10
10
|
|
|
11
11
|
Optionally you can enable a visual interface:
|
|
12
12
|
|
|
@@ -16,6 +16,8 @@ Alternative versions:
|
|
|
16
16
|
|
|
17
17
|
- Core dependency - [Ruby](https://github.com/pawurb/ruby-pg-extras)
|
|
18
18
|
|
|
19
|
+
- [Rust](https://github.com/pawurb/rust-pg-extras)
|
|
20
|
+
|
|
19
21
|
- [NodeJS](https://github.com/pawurb/node-postgres-extras)
|
|
20
22
|
|
|
21
23
|
- [Elixir](https://github.com/pawurb/ecto_psql_extras)
|
|
@@ -109,6 +111,8 @@ By default, queries target the `public` schema of the database. You can specify
|
|
|
109
111
|
RailsPgExtras.table_cache_hit(args: { schema: "my_schema" })
|
|
110
112
|
```
|
|
111
113
|
|
|
114
|
+
You can customize the default `public` schema by setting `ENV['PG_EXTRAS_SCHEMA']` value.
|
|
115
|
+
|
|
112
116
|
## Diagnose report
|
|
113
117
|
|
|
114
118
|
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:
|
|
@@ -544,7 +548,7 @@ This command displays the total size of each table and materialized view in the
|
|
|
544
548
|
### `unused_indexes`
|
|
545
549
|
|
|
546
550
|
```ruby
|
|
547
|
-
RailsPgExtras.unused_indexes(args: { max_scans:
|
|
551
|
+
RailsPgExtras.unused_indexes(args: { max_scans: 50 })
|
|
548
552
|
|
|
549
553
|
$ rake pg_extras:unused_indexes
|
|
550
554
|
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
-
require
|
|
2
|
+
require "rspec/core/rake_task"
|
|
3
3
|
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
5
|
|
|
6
|
-
desc
|
|
6
|
+
desc "Test all PG versions"
|
|
7
7
|
task :test_all do
|
|
8
8
|
system("PG_VERSION=11 bundle exec rspec spec/ && PG_VERSION=12 bundle exec rspec spec/ && PG_VERSION=13 bundle exec rspec spec/ && PG_VERSION=14 bundle exec rspec spec/")
|
|
9
9
|
end
|
|
10
|
-
|
|
@@ -9,17 +9,17 @@ module RailsPgExtras::Web
|
|
|
9
9
|
REQUIRED_EXTENSIONS = {
|
|
10
10
|
pg_stat_statements: %i[calls outliers pg_stat_statements_reset],
|
|
11
11
|
pg_buffercache: %i[buffercache_stats buffercache_usage],
|
|
12
|
-
sslinfo: %i[ssl_used]
|
|
12
|
+
sslinfo: %i[ssl_used],
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
ACTIONS = %i[kill_all pg_stat_statements_reset add_extensions]
|
|
16
16
|
|
|
17
|
-
if ENV[
|
|
18
|
-
http_basic_authenticate_with name: ENV.fetch(
|
|
17
|
+
if ENV["RAILS_PG_EXTRAS_USER"].present? && ENV["RAILS_PG_EXTRAS_PASSWORD"].present?
|
|
18
|
+
http_basic_authenticate_with name: ENV.fetch("RAILS_PG_EXTRAS_USER"), password: ENV.fetch("RAILS_PG_EXTRAS_PASSWORD")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def validate_credentials!
|
|
22
|
-
if (ENV[
|
|
22
|
+
if (ENV["RAILS_PG_EXTRAS_USER"].blank? || ENV["RAILS_PG_EXTRAS_PASSWORD"].blank?) && !RailsPgExtras.configuration.public_dashboard
|
|
23
23
|
raise "Missing credentials for rails-pg-extras dashboard! If you want to enable public dashboard please set RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true"
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -38,7 +38,7 @@ module RailsPgExtras::Web
|
|
|
38
38
|
return @unavailable_extensions if defined?(@unavailable_extensions)
|
|
39
39
|
|
|
40
40
|
enabled_extensions = ActiveRecord::Base.connection.extensions
|
|
41
|
-
@unavailable_extensions = REQUIRED_EXTENSIONS.delete_if { |ext| ext.to_s.in?(enabled_extensions)
|
|
41
|
+
@unavailable_extensions = REQUIRED_EXTENSIONS.delete_if { |ext| ext.to_s.in?(enabled_extensions) }
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<h1 class="font-bold text-xl my-5">Diagnose</h1>
|
|
2
2
|
<table class="w-full font-mono border-collapse border my-5">
|
|
3
3
|
<% RailsPgExtras.diagnose(in_format: :hash).each do |diagnosis| %>
|
|
4
|
-
<tr class="<%= diagnosis[:ok] ?
|
|
4
|
+
<tr class="<%= diagnosis[:ok] ? "bg-green-300" : "bg-red-300" %>">
|
|
5
5
|
<td class='p-1 border font-bold'><%= diagnosis[:check_name] %></td>
|
|
6
6
|
<td class='p-1 border'><%= diagnosis[:message] %></td>
|
|
7
7
|
</tr>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<div class="text-red-500 p-3 font-mono my-5">
|
|
2
|
-
<% unavailable_extensions.each do |extension, queries| %>
|
|
2
|
+
<% unavailable_extensions.each do |extension, queries| %>
|
|
3
3
|
WARNING: Queries <%= queries.map { |q| "<b><u>#{q}</u></b>" }.join(", ").html_safe %> require extension: <b><%= extension %></b>
|
|
4
4
|
<br>
|
|
5
|
-
<% end %>
|
|
5
|
+
<% end %>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
|
-
<% if RailsPgExtras::Web.action_enabled?(:add_extensions) %>
|
|
9
|
-
<%= link_to "Enable extensions", add_extensions_action_path,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<% end %>
|
|
8
|
+
<% if RailsPgExtras::Web.action_enabled?(:add_extensions) %>
|
|
9
|
+
<%= link_to "Enable extensions", add_extensions_action_path,
|
|
10
|
+
method: "post",
|
|
11
|
+
data: {
|
|
12
|
+
confirm: "This command will enable following extensions: #{unavailable_extensions.keys.join(", ")}. Do you want to proceeed?",
|
|
13
|
+
}, class: "border p-3 bg-green-500 text-white hover:bg-green-600 font-bold rounded" %>
|
|
14
|
+
<% end %>
|
|
15
15
|
|
|
@@ -6,20 +6,18 @@
|
|
|
6
6
|
<h1 class="font-bold text-xl my-5">Actions</h1>
|
|
7
7
|
|
|
8
8
|
<% if RailsPgExtras::Web.action_enabled?(:kill_all) %>
|
|
9
|
-
<%= link_to "kill_all",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
%>
|
|
9
|
+
<%= link_to "kill_all", kill_all_action_path,
|
|
10
|
+
method: "post",
|
|
11
|
+
data: {
|
|
12
|
+
confirm: "This commands kills all the currently active connections to the database. Do you want to proceed?",
|
|
13
|
+
},
|
|
14
|
+
class: "border p-3 bg-red-500 text-white hover:bg-red-600 font-bold rounded" %>
|
|
16
15
|
<% end %>
|
|
17
16
|
|
|
18
17
|
<% if RailsPgExtras::Web.action_enabled?(:pg_stat_statements_reset) && unavailable_extensions.exclude?(:pg_stat_statements) %>
|
|
19
18
|
<%= link_to "pg_stat_statements_reset", pg_stat_statements_reset_action_path,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
%>
|
|
19
|
+
method: "post",
|
|
20
|
+
data: {
|
|
21
|
+
confirm: "This command discards all statistics gathered so far by pg_stat_statements. Do you want to proceed?",
|
|
22
|
+
}, class: "border p-3 bg-blue-500 text-white hover:bg-blue-600 font-bold rounded" %>
|
|
25
23
|
<% end %>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
<%= content_for :title, params[:query_name].presence || "pg_extras" %>
|
|
2
|
-
<%= render "rails_pg_extras/web/shared/queries_selector" %>
|
|
1
|
+
<%= content_for :title, params[:query_name].presence || "pg_extras" %>
|
|
2
|
+
<%= render "rails_pg_extras/web/shared/queries_selector" %>
|
|
3
3
|
|
|
4
|
-
<% if @error %>
|
|
4
|
+
<% if @error %>
|
|
5
5
|
<div class="text-red-500 p-3 font-mono my-5"><%= @error %></div>
|
|
6
|
-
<% else %>
|
|
7
|
-
<% if @result&.any? %>
|
|
8
|
-
<%= render "result",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<% else %>
|
|
6
|
+
<% else %>
|
|
7
|
+
<% if @result&.any? %>
|
|
8
|
+
<%= render "result",
|
|
9
|
+
title: RubyPgExtras.description_for(query_name: @query_name),
|
|
10
|
+
headers: @result[0].keys,
|
|
11
|
+
rows: @result.values %>
|
|
12
|
+
<% else %>
|
|
14
13
|
<div class="font-mono p-3 bg-gray-100 mt-3">No results</div>
|
|
15
|
-
<% end %>
|
|
16
|
-
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
<% end %>
|
|
17
16
|
|
|
18
17
|
<style>
|
|
19
18
|
@media print {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
<%= form_tag queries_path, id: "queries", method: :get do |f| %>
|
|
2
|
-
<%= select_tag :query_name, options_for_select(@all_queries, params[:query_name]),
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<% end %>
|
|
1
|
+
<%= form_tag queries_path, id: "queries", method: :get do |f| %>
|
|
2
|
+
<%= select_tag :query_name, options_for_select(@all_queries, params[:query_name]),
|
|
3
|
+
{ prompt: "--- select query ---", class: "border p-2 font-bold", autofocus: true } %>
|
|
4
|
+
<% end %>
|
|
6
5
|
|
|
7
6
|
<%= javascript_tag nonce: true do -%>
|
|
8
7
|
document.getElementById('queries').addEventListener('change', (e) => {
|
data/config/routes.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
RailsPgExtras::Web::Engine.routes.draw do
|
|
2
2
|
resources :queries, only: [:index]
|
|
3
3
|
|
|
4
|
-
post "/actions/kill_all"
|
|
5
|
-
post "/actions/pg_stat_statements_reset"
|
|
6
|
-
post "/actions/add_extensions"
|
|
4
|
+
post "/actions/kill_all", to: "actions#kill_all", as: :kill_all_action
|
|
5
|
+
post "/actions/pg_stat_statements_reset", to: "actions#pg_stat_statements_reset", as: :pg_stat_statements_reset_action
|
|
6
|
+
post "/actions/add_extensions", to: "actions#add_extensions", as: :add_extensions_action
|
|
7
7
|
|
|
8
8
|
root to: "queries#index"
|
|
9
9
|
end
|
data/lib/rails-pg-extras.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
3
|
+
require "terminal-table"
|
|
4
|
+
require "ruby-pg-extras"
|
|
5
|
+
require "rails_pg_extras/diagnose_data"
|
|
6
|
+
require "rails_pg_extras/diagnose_print"
|
|
7
|
+
require "rails_pg_extras/index_info"
|
|
8
|
+
require "rails_pg_extras/index_info_print"
|
|
9
|
+
require "rails_pg_extras/table_info"
|
|
10
|
+
require "rails_pg_extras/table_info_print"
|
|
11
11
|
|
|
12
12
|
module RailsPgExtras
|
|
13
13
|
QUERIES = RubyPgExtras::QUERIES
|
|
@@ -19,7 +19,7 @@ module RailsPgExtras
|
|
|
19
19
|
run_query(
|
|
20
20
|
query_name: query_name,
|
|
21
21
|
in_format: options.fetch(:in_format, :display_table),
|
|
22
|
-
args: options.fetch(:args, {})
|
|
22
|
+
args: options.fetch(:args, {}),
|
|
23
23
|
)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -30,7 +30,7 @@ module RailsPgExtras
|
|
|
30
30
|
FROM pg_available_extensions
|
|
31
31
|
WHERE name = 'pg_stat_statements'"
|
|
32
32
|
if (version = RailsPgExtras.connection.execute(pg_stat_statements_version_sql)
|
|
33
|
-
|
|
33
|
+
.to_a[0].fetch("installed_version", nil))
|
|
34
34
|
if Gem::Version.new(version) < Gem::Version.new(NEW_PG_STAT_STATEMENTS)
|
|
35
35
|
query_name = "#{query_name}_legacy".to_sym
|
|
36
36
|
end
|
|
@@ -38,17 +38,17 @@ module RailsPgExtras
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
sql = if (custom_args = DEFAULT_ARGS[query_name].merge(args)) != {}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
RubyPgExtras.sql_for(query_name: query_name) % custom_args
|
|
42
|
+
else
|
|
43
|
+
RubyPgExtras.sql_for(query_name: query_name)
|
|
44
|
+
end
|
|
45
45
|
|
|
46
46
|
result = connection.execute(sql)
|
|
47
47
|
|
|
48
48
|
RubyPgExtras.display_result(
|
|
49
49
|
result,
|
|
50
50
|
title: RubyPgExtras.description_for(query_name: query_name),
|
|
51
|
-
in_format: in_format
|
|
51
|
+
in_format: in_format,
|
|
52
52
|
)
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -76,10 +76,10 @@ module RailsPgExtras
|
|
|
76
76
|
sql_duration = 0
|
|
77
77
|
|
|
78
78
|
method_name = if ActiveSupport::Notifications.respond_to?(:monotonic_subscribe)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
:monotonic_subscribe
|
|
80
|
+
else
|
|
81
|
+
:subscribe
|
|
82
|
+
end
|
|
83
83
|
|
|
84
84
|
subscriber = ActiveSupport::Notifications.public_send(method_name, "sql.active_record") do |_name, start, finish, _id, payload|
|
|
85
85
|
unless payload[:name] =~ /SCHEMA/
|
|
@@ -115,11 +115,10 @@ module RailsPgExtras
|
|
|
115
115
|
count: queries.reduce(0) { |agg, val| agg + val[1].fetch(:count) },
|
|
116
116
|
queries: queries,
|
|
117
117
|
total_duration: total_duration.round(2),
|
|
118
|
-
sql_duration: sql_duration.round(2)
|
|
118
|
+
sql_duration: sql_duration.round(2),
|
|
119
119
|
}
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
|
|
123
122
|
def self.index_info(args: {}, in_format: :display_table)
|
|
124
123
|
data = RailsPgExtras::IndexInfo.call(args[:table_name])
|
|
125
124
|
|
|
@@ -149,7 +148,7 @@ module RailsPgExtras
|
|
|
149
148
|
end
|
|
150
149
|
|
|
151
150
|
def self.connection
|
|
152
|
-
if (db_url = ENV[
|
|
151
|
+
if (db_url = ENV["RAILS_PG_EXTRAS_DATABASE_URL"])
|
|
153
152
|
ActiveRecord::Base.establish_connection(db_url).connection
|
|
154
153
|
else
|
|
155
154
|
ActiveRecord::Base.connection
|
|
@@ -157,6 +156,6 @@ module RailsPgExtras
|
|
|
157
156
|
end
|
|
158
157
|
end
|
|
159
158
|
|
|
160
|
-
require
|
|
161
|
-
require
|
|
162
|
-
require
|
|
159
|
+
require "rails_pg_extras/web"
|
|
160
|
+
require "rails_pg_extras/configuration"
|
|
161
|
+
require "rails_pg_extras/railtie" if defined?(Rails)
|
data/rails-pg-extras.gemspec
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
lib = File.expand_path(
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require
|
|
4
|
+
require "rails_pg_extras/version"
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name
|
|
8
|
-
s.version
|
|
9
|
-
s.authors
|
|
10
|
-
s.email
|
|
11
|
-
s.summary
|
|
12
|
-
s.description
|
|
13
|
-
s.homepage
|
|
14
|
-
s.files
|
|
15
|
-
s.test_files
|
|
7
|
+
s.name = "rails-pg-extras"
|
|
8
|
+
s.version = RailsPgExtras::VERSION
|
|
9
|
+
s.authors = ["pawurb"]
|
|
10
|
+
s.email = ["contact@pawelurbanek.com"]
|
|
11
|
+
s.summary = %q{ Rails PostgreSQL performance database insights }
|
|
12
|
+
s.description = %q{ Rails port of Heroku PG Extras. The goal of this project is to provide a powerful insights into PostgreSQL database for Ruby on Rails apps that are not using the default Heroku PostgreSQL plugin. }
|
|
13
|
+
s.homepage = "http://github.com/pawurb/rails-pg-extras"
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = s.files.grep(%r{^(spec)/})
|
|
16
16
|
s.require_paths = ["lib"]
|
|
17
|
-
s.license
|
|
17
|
+
s.license = "MIT"
|
|
18
18
|
s.add_dependency "ruby-pg-extras", RailsPgExtras::VERSION
|
|
19
19
|
s.add_dependency "rails"
|
|
20
20
|
s.add_development_dependency "rake"
|
|
21
21
|
s.add_development_dependency "rspec"
|
|
22
|
+
s.add_development_dependency "rufo"
|
|
22
23
|
|
|
23
24
|
if s.respond_to?(:metadata=)
|
|
24
25
|
s.metadata = { "rubygems_mfa_required" => "true" }
|
data/spec/smoke_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "rails-pg-extras"
|
|
5
5
|
|
|
6
6
|
describe RailsPgExtras do
|
|
7
7
|
RailsPgExtras::QUERIES.each do |query_name|
|
|
@@ -9,7 +9,7 @@ describe RailsPgExtras do
|
|
|
9
9
|
expect do
|
|
10
10
|
RailsPgExtras.run_query(
|
|
11
11
|
query_name: query_name,
|
|
12
|
-
in_format: :hash
|
|
12
|
+
in_format: :hash,
|
|
13
13
|
)
|
|
14
14
|
end.not_to raise_error
|
|
15
15
|
end
|
|
@@ -35,12 +35,12 @@ describe RailsPgExtras do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "supports custom RAILS_PG_EXTRAS_DATABASE_URL" do
|
|
38
|
-
ENV[
|
|
38
|
+
ENV["RAILS_PG_EXTRAS_DATABASE_URL"] = ENV["DATABASE_URL"]
|
|
39
39
|
|
|
40
40
|
expect do
|
|
41
41
|
RailsPgExtras.calls
|
|
42
42
|
end.not_to raise_error
|
|
43
43
|
|
|
44
|
-
ENV[
|
|
44
|
+
ENV["RAILS_PG_EXTRAS_DATABASE_URL"] = nil
|
|
45
45
|
end
|
|
46
46
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require_relative
|
|
3
|
+
require "rubygems"
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "active_record"
|
|
6
|
+
require_relative "../lib/rails-pg-extras"
|
|
7
7
|
|
|
8
8
|
pg_version = ENV["PG_VERSION"]
|
|
9
9
|
|
|
10
10
|
port = if pg_version == "11"
|
|
11
|
-
|
|
12
|
-
elsif pg_version == "12"
|
|
13
|
-
|
|
14
|
-
elsif pg_version == "13"
|
|
15
|
-
|
|
16
|
-
elsif pg_version == "14"
|
|
17
|
-
|
|
18
|
-
else
|
|
19
|
-
|
|
20
|
-
end
|
|
11
|
+
"5432"
|
|
12
|
+
elsif pg_version == "12"
|
|
13
|
+
"5433"
|
|
14
|
+
elsif pg_version == "13"
|
|
15
|
+
"5434"
|
|
16
|
+
elsif pg_version == "14"
|
|
17
|
+
"5435"
|
|
18
|
+
else
|
|
19
|
+
"5432"
|
|
20
|
+
end
|
|
21
21
|
|
|
22
22
|
ENV["DATABASE_URL"] ||= "postgresql://postgres:secret@localhost:#{port}/rails-pg-extras-test"
|
|
23
23
|
|
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: 5.
|
|
4
|
+
version: 5.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- pawurb
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-09-19 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: 5.
|
|
19
|
+
version: 5.4.0
|
|
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: 5.
|
|
26
|
+
version: 5.4.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rails
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rufo
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
description: " Rails port of Heroku PG Extras. The goal of this project is to provide
|
|
70
84
|
a powerful insights into PostgreSQL database for Ruby on Rails apps that are not
|
|
71
85
|
using the default Heroku PostgreSQL plugin. "
|
|
@@ -132,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
132
146
|
- !ruby/object:Gem::Version
|
|
133
147
|
version: '0'
|
|
134
148
|
requirements: []
|
|
135
|
-
rubygems_version: 3.
|
|
149
|
+
rubygems_version: 3.5.4
|
|
136
150
|
signing_key:
|
|
137
151
|
specification_version: 4
|
|
138
152
|
summary: Rails PostgreSQL performance database insights
|