rails-pg-extras-web 3.2.3 → 4.0.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: f5769767f9eb5b29c53a699d4763b2b4856108519115f35fa335045b8fe5cee7
4
- data.tar.gz: 9c6d01369b03ff51fed482c81b47592d6d7d9e15a56c3f72ec439d106a5e679d
3
+ metadata.gz: 6bf29ec509433273d9fb2941cbb700e8b863ed5e1b4357066b8cf082070a1c4b
4
+ data.tar.gz: 3920070598fced77e2c0917ef9469741229b65a251e2b96664cbd490db34a4dd
5
5
  SHA512:
6
- metadata.gz: 72bf45a137abf870cd3364d76a569d4702a6f5522670d8a1a1d5130c27ee9ea4d3aca4f738e761d0a12490e9d4d4697f9070369fe8ccfe5315cb8395923f1517
7
- data.tar.gz: '000914f94a2e2daa9eac47e97ec71c8ea7fa2ec007bf2a73510572d4992c04b67651caa9c9a65d63f2324a12964771776e1fec69611131093535d2bdbf2adc0f'
6
+ metadata.gz: be18f1163abd8ac9309d9a454a12b7447abc980a9c198799a719bdcccdb3277849bd981cd4d0c0b73ca385f44f249a2e58185d39dd37162c106ba1ce312aab44
7
+ data.tar.gz: b2aa9a982e6f7db441985de42d60e5d86ad88d47c1e739b47c7187ea3ac19891c8fa1dc1e1770387483f2b606bdc009697a90bae9101d414d6edb0972a02cbe4
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
+ # Important!
2
+ RailsPgExtrasWeb is merged with [rails-pg-extras](https://github.com/pawurb/rails-pg-extras) since version **4.0.0**. Please used this gem instead.
3
+
4
+
1
5
  # RailsPgExtrasWeb
2
6
  Web UI for [rails-pg-extras](https://github.com/pawurb/rails-pg-extras)
3
7
 
4
- ![WebUI](https://raw.githubusercontent.com/pawurb/rails-pg-extras/master/rails-pg-extras-web.png)
8
+ ![WebUI](https://github.com/pawurb/rails-pg-extras/raw/master/pg-extras-ui.png)
5
9
 
6
10
  ## Installation
7
11
  Add this line to your application's Gemfile:
@@ -1,5 +1,2 @@
1
- require "rails_pg_extras_web/engine"
2
-
3
- module RailsPgExtrasWeb
4
- # Your code goes here...
5
- end
1
+ require "rails_pg_extras_web/version"
2
+ require "rails-pg-extras"
@@ -1,3 +1,3 @@
1
1
  module RailsPgExtrasWeb
2
- VERSION = '3.2.3'
2
+ VERSION = '4.0.0'
3
3
  end
metadata CHANGED
@@ -1,44 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Mazur
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-18 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: pg
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.2'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rails-pg-extras
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '3.2'
19
+ version: 4.0.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '3.2'
41
- description:
26
+ version: 4.0.0
27
+ description:
42
28
  email:
43
29
  - tomasz.mazur@hey.com
44
30
  executables: []
@@ -48,25 +34,15 @@ files:
48
34
  - MIT-LICENSE
49
35
  - README.md
50
36
  - Rakefile
51
- - app/controllers/rails_pg_extras_web/actions_controller.rb
52
- - app/controllers/rails_pg_extras_web/application_controller.rb
53
- - app/controllers/rails_pg_extras_web/queries_controller.rb
54
- - app/views/layouts/rails_pg_extras_web/application.html.erb
55
- - app/views/rails_pg_extras_web/queries/_diagnose.html.erb
56
- - app/views/rails_pg_extras_web/queries/_result.html.erb
57
- - app/views/rails_pg_extras_web/queries/_unavailable_extensions_warning.html.erb
58
- - app/views/rails_pg_extras_web/queries/index.html.erb
59
- - app/views/rails_pg_extras_web/queries/show.html.erb
60
- - app/views/rails_pg_extras_web/shared/_queries_selector.html.erb
61
- - config/routes.rb
62
37
  - lib/rails-pg-extras-web.rb
63
- - lib/rails_pg_extras_web/engine.rb
64
38
  - lib/rails_pg_extras_web/version.rb
65
39
  homepage: https://github.com/defkode/rails-pg-extras-web
66
40
  licenses:
67
41
  - MIT
68
- metadata: {}
69
- post_install_message:
42
+ metadata:
43
+ rubygems_mfa_required: 'true'
44
+ post_install_message: rails-pg-extras-web is deprecated. Please use rails-pg-extras
45
+ instead (>= 4.0.0)
70
46
  rdoc_options: []
71
47
  require_paths:
72
48
  - lib
@@ -81,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
57
  - !ruby/object:Gem::Version
82
58
  version: '0'
83
59
  requirements: []
84
- rubygems_version: 3.2.32
85
- signing_key:
60
+ rubygems_version: 3.1.6
61
+ signing_key:
86
62
  specification_version: 4
87
63
  summary: Web UI for rails-pg-extras
88
64
  test_files: []
@@ -1,26 +0,0 @@
1
- module RailsPgExtrasWeb
2
- class ActionsController < ApplicationController
3
- def kill_all
4
- run(:kill_all)
5
- end
6
-
7
- def pg_stat_statements_reset
8
- run(:pg_stat_statements_reset)
9
- end
10
-
11
- def add_extensions
12
- run(:add_extensions)
13
- end
14
-
15
- private
16
-
17
- def run(action)
18
- begin
19
- RailsPGExtras.run_query(query_name: action, in_format: :raw)
20
- redirect_to root_path, notice: "Successfully ran #{action}"
21
- rescue ActiveRecord::StatementInvalid => e
22
- redirect_to root_path, alert: "Error: #{e.message}"
23
- end
24
- end
25
- end
26
- end
@@ -1,20 +0,0 @@
1
- require "rails-pg-extras"
2
- require "rails-pg-extras/version"
3
-
4
- module RailsPgExtrasWeb
5
- class ApplicationController < ActionController::Base
6
- layout "rails_pg_extras_web/application"
7
-
8
- REQUIRED_EXTENSIONS = {
9
- pg_stat_statements: %i[calls outliers pg_stat_statements_reset],
10
- pg_buffercache: %i[buffercache_stats buffercache_usage],
11
- sslinfo: %i[ssl_used]
12
- }
13
-
14
- ACTIONS = %i[kill_all pg_stat_statements_reset add_extensions]
15
-
16
- if Rails.env.production? && ENV['PG_EXTRAS_USER'].present? && ENV['PG_EXTRAS_PASSWORD'].present?
17
- http_basic_authenticate_with name: ENV['PG_EXTRAS_USER'], password: ENV['PG_EXTRAS_PASSWORD']
18
- end
19
- end
20
- end
@@ -1,44 +0,0 @@
1
- module RailsPgExtrasWeb
2
- class QueriesController < ApplicationController
3
- before_action :load_queries
4
- helper_method :unavailable_extensions
5
-
6
- def index
7
- if params[:query_name].present?
8
- @query_name = params[:query_name].to_sym.presence_in(@all_queries.keys)
9
- return unless @query_name
10
-
11
- begin
12
- @result = RailsPGExtras.run_query(query_name: @query_name.to_sym, in_format: :raw)
13
- rescue ActiveRecord::StatementInvalid => e
14
- @error = e.message
15
- end
16
-
17
- render :show
18
- end
19
- end
20
-
21
- private
22
-
23
- def load_queries
24
- @all_queries = (RailsPGExtras::QUERIES - ACTIONS).inject({}) do |memo, query_name|
25
- unless query_name.in? %i[mandelbrot]
26
- memo[query_name] = { disabled: query_disabled?(query_name) }
27
- end
28
-
29
- memo
30
- end
31
- end
32
-
33
- def query_disabled?(query_name)
34
- unavailable_extensions.values.flatten.include?(query_name)
35
- end
36
-
37
- def unavailable_extensions
38
- return @unavailable_extensions if defined?(@unavailable_extensions)
39
-
40
- enabled_extensions = ActiveRecord::Base.connection.extensions
41
- @unavailable_extensions = REQUIRED_EXTENSIONS.delete_if { |ext| ext.to_s.in?(enabled_extensions) }
42
- end
43
- end
44
- end
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= content_for :title %> | v<%= RailsPGExtras::VERSION %></title>
5
- <%= javascript_include_tag "https://unpkg.com/@rails/ujs" %>
6
- <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body class="p-5 text-xs">
10
- <% if flash[:notice] %>
11
- <div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-4" role="alert">
12
- <p class="font-bold">Notice</p>
13
- <p><%= flash[:notice] %></p>
14
- </div>
15
- <% end %>
16
-
17
- <% if flash[:alert] %>
18
- <div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4" role="alert">
19
- <p class="font-bold">Alert</p>
20
- <p><%= flash[:alert] %></p>
21
- </div>
22
- <% end %>
23
-
24
- <%= yield %>
25
- </body>
26
- </html>
@@ -1,9 +0,0 @@
1
- <h1 class="font-bold text-xl my-5">Diagnose</h1>
2
- <table class="w-full font-mono border-collapse border my-5">
3
- <% RailsPGExtras.diagnose(in_format: :hash).each do |diagnosis| %>
4
- <tr class="<%= diagnosis[:ok] ? 'bg-green-300' : 'bg-red-300' %>">
5
- <td class='p-1 border font-bold'><%= diagnosis[:check_name] %></td>
6
- <td class='p-1 border'><%= diagnosis[:message] %></td>
7
- </tr>
8
- <% end %>
9
- </table>
@@ -1,21 +0,0 @@
1
- <h1 class="font-bold text-xl my-5"><%= title %></h1>
2
-
3
- <table class="w-full font-mono border-collapse border my-5">
4
- <thead>
5
- <tr class="bg-gray-300">
6
- <% headers.each do |header| %>
7
- <th class="p-2 border text-left"><%= header %></th>
8
- <% end %>
9
- </tr>
10
- </thead>
11
- <tbody>
12
- <% rows.each.with_index do |row, i| %>
13
- <tr class="hover:bg-gray-400 hover:text-white <%= i.even? ? "bg-gray-100" : "bg-gray-200" %>">
14
- <% row.each do |column| %>
15
- <td class="p-1 border"><%= column %></td>
16
- <% end %>
17
- </tr>
18
- <% end %>
19
- </tbody>
20
- </table>
21
- <span class="italic">run_at: <%= Time.now.utc %></span>
@@ -1,13 +0,0 @@
1
- <div class="text-red-500 p-3 font-mono my-5">
2
- <% unavailable_extensions.each do |extension, queries| %>
3
- WARNING: Queries <%= queries.map { |q| "<b><u>#{q}</u></b>" }.join(", ").html_safe %> require extension: <b><%= extension %></b>
4
- <br>
5
- <% end %>
6
- </div>
7
-
8
- <%= link_to "Enable extensions", add_extensions_action_path,
9
- method: "post",
10
- data: {
11
- confirm: "This command will enable following extensions: #{unavailable_extensions.keys.join(', ')}. Do you want to proceeed?"
12
- }, class: 'border p-3 bg-green-500 text-white hover:bg-green-600 font-bold rounded' %>
13
-
@@ -1,21 +0,0 @@
1
- <%= content_for :title, "pg_extras" %>
2
- <%= render "rails_pg_extras_web/shared/queries_selector" %>
3
- <%= render "unavailable_extensions_warning" if unavailable_extensions.any? %>
4
- <%= render "diagnose" %>
5
-
6
- <h1 class="font-bold text-xl my-5">Actions</h1>
7
-
8
- <%= link_to "kill_all", kill_all_action_path,
9
- method: "post",
10
- data: {
11
- confirm: "This commands kills all the currently active connections to the database. Do you want to proceed?"
12
- },
13
- class: 'border p-3 bg-red-500 text-white hover:bg-red-600 font-bold rounded'
14
- %>
15
-
16
- <%= link_to "pg_stat_statements_reset", pg_stat_statements_reset_action_path,
17
- method: "post",
18
- data: {
19
- confirm: "This command discards all statistics gathered so far by pg_stat_statements. Do you want to proceed?"
20
- }, class: 'border p-3 bg-blue-500 text-white hover:bg-blue-600 font-bold rounded'
21
- %>
@@ -1,24 +0,0 @@
1
- <%= content_for :title, params[:query_name].presence || "pg_extras" %>
2
- <%= render "rails_pg_extras_web/shared/queries_selector" %>
3
-
4
- <% if @error %>
5
- <div class="text-red-500 p-3 font-mono my-5"><%= @error %></div>
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
- %>
13
- <% else %>
14
- <div class="font-mono p-3 bg-gray-100 mt-3">No results</div>
15
- <% end %>
16
- <% end %>
17
-
18
- <style>
19
- @media print {
20
- form {
21
- display: none
22
- }
23
- }
24
- </style>
@@ -1,11 +0,0 @@
1
- <%= form_with url: queries_path, id: "queries", method: :get do |f| %>
2
- <%= f.select :query_name, options_for_select(@all_queries, params[:query_name]),
3
- {prompt: "--- select query ---"},
4
- {class: "border p-2 font-bold", autofocus: true}
5
- %>
6
- <% end %>
7
- <script>
8
- document.getElementById('queries').addEventListener('change', (e) => {
9
- e.target.form.submit()
10
- })
11
- </script>
data/config/routes.rb DELETED
@@ -1,9 +0,0 @@
1
- RailsPgExtrasWeb::Engine.routes.draw do
2
- resources :queries, only: [:index]
3
-
4
- post "/actions/kill_all" => "actions#kill_all", as: :kill_all_action
5
- post "/actions/pg_stat_statements_reset" => "actions#pg_stat_statements_reset", as: :pg_stat_statements_reset_action
6
- post "/actions/add_extensions" => "actions#add_extensions", as: :add_extensions_action
7
-
8
- root to: "queries#index"
9
- end
@@ -1,5 +0,0 @@
1
- module RailsPgExtrasWeb
2
- class Engine < ::Rails::Engine
3
- isolate_namespace RailsPgExtrasWeb
4
- end
5
- end