rails-pg-extras-web 2.2.0 → 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: a2a3e9fef31d95866c584c87bb8f01cc3f150f086500b01d0dbb05ebfc6d9533
4
- data.tar.gz: 7d1974687a38bd6792dab2aeacaeec4375e391052bb029c5dfd8dfc66f303085
3
+ metadata.gz: 6bf29ec509433273d9fb2941cbb700e8b863ed5e1b4357066b8cf082070a1c4b
4
+ data.tar.gz: 3920070598fced77e2c0917ef9469741229b65a251e2b96664cbd490db34a4dd
5
5
  SHA512:
6
- metadata.gz: 92f4793d25c4edaf1943daa7cb36af925b74ce9219ee7c87e410959d902ea2b0291b533011468c4f7e4bf68409af2c121e2288216cb3cfcc656ff292a3c24235
7
- data.tar.gz: 249851bc75a35aa16f904e998ac96d461e8f01b8ab6c875b6c15414b8af0bd808e6b7520e97835f2801b46e458b8c16bd0e1000d2683db0238d99dcfb552090e
6
+ metadata.gz: be18f1163abd8ac9309d9a454a12b7447abc980a9c198799a719bdcccdb3277849bd981cd4d0c0b73ca385f44f249a2e58185d39dd37162c106ba1ce312aab44
7
+ data.tar.gz: b2aa9a982e6f7db441985de42d60e5d86ad88d47c1e739b47c7187ea3ac19891c8fa1dc1e1770387483f2b606bdc009697a90bae9101d414d6edb0972a02cbe4
data/README.md CHANGED
@@ -1,6 +1,12 @@
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
 
8
+ ![WebUI](https://github.com/pawurb/rails-pg-extras/raw/master/pg-extras-ui.png)
9
+
4
10
  ## Installation
5
11
  Add this line to your application's Gemfile:
6
12
 
@@ -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 = '2.2.0'
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: 2.2.0
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-10-26 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: '2.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: '2.2'
41
- description:
26
+ version: 4.0.0
27
+ description:
42
28
  email:
43
29
  - tomasz.mazur@hey.com
44
30
  executables: []
@@ -48,23 +34,15 @@ files:
48
34
  - MIT-LICENSE
49
35
  - README.md
50
36
  - Rakefile
51
- - app/controllers/rails_pg_extras_web/application_controller.rb
52
- - app/controllers/rails_pg_extras_web/queries_controller.rb
53
- - app/views/layouts/rails_pg_extras_web/application.html.erb
54
- - app/views/rails_pg_extras_web/queries/_result.html.erb
55
- - app/views/rails_pg_extras_web/queries/_unavailable_extensions_warning.html.erb
56
- - app/views/rails_pg_extras_web/queries/index.html.erb
57
- - app/views/rails_pg_extras_web/queries/show.html.erb
58
- - app/views/rails_pg_extras_web/shared/_queries_selector.html.erb
59
- - config/routes.rb
60
37
  - lib/rails-pg-extras-web.rb
61
- - lib/rails_pg_extras_web/engine.rb
62
38
  - lib/rails_pg_extras_web/version.rb
63
39
  homepage: https://github.com/defkode/rails-pg-extras-web
64
40
  licenses:
65
41
  - MIT
66
- metadata: {}
67
- 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)
68
46
  rdoc_options: []
69
47
  require_paths:
70
48
  - lib
@@ -80,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
58
  version: '0'
81
59
  requirements: []
82
60
  rubygems_version: 3.1.6
83
- signing_key:
61
+ signing_key:
84
62
  specification_version: 4
85
63
  summary: Web UI for rails-pg-extras
86
64
  test_files: []
@@ -1,11 +0,0 @@
1
- require "rails-pg-extras"
2
-
3
- module RailsPgExtrasWeb
4
- class ApplicationController < ActionController::Base
5
- layout "rails_pg_extras_web/application"
6
-
7
- if Rails.env.production? && ENV['PG_EXTRAS_USER'].present? && ENV['PG_EXTRAS_PASSWORD'].present?
8
- http_basic_authenticate_with name: ENV['PG_EXTRAS_USER'], password: ENV['PG_EXTRAS_PASSWORD']
9
- end
10
- end
11
- end
@@ -1,50 +0,0 @@
1
- module RailsPgExtrasWeb
2
- class QueriesController < ApplicationController
3
- REQUIRED_EXTENSIONS = {
4
- pg_stat_statements: %i[calls outliers],
5
- pg_buffercache: %i[buffercache_stats buffercache_usage],
6
- sslinfo: %i[ssl_used]
7
- }
8
-
9
- before_action :load_queries
10
- helper_method :unavailable_extensions
11
-
12
- def index
13
- if params[:query_name].present?
14
- @query_name = params[:query_name].to_sym.presence_in(@all_queries.keys)
15
- return unless @query_name
16
-
17
- begin
18
- @result = RailsPGExtras.run_query(query_name: @query_name.to_sym, in_format: :raw)
19
- rescue ActiveRecord::StatementInvalid => e
20
- @error = e.message
21
- end
22
-
23
- render :show
24
- end
25
- end
26
-
27
- private
28
-
29
- def load_queries
30
- @all_queries = RailsPGExtras::QUERIES.inject({}) do |memo, query_name|
31
- unless query_name.in? %i[kill_all mandelbrot]
32
- memo[query_name] = { disabled: query_disabled?(query_name) }
33
- end
34
-
35
- memo
36
- end
37
- end
38
-
39
- def query_disabled?(query_name)
40
- unavailable_extensions.values.flatten.include?(query_name)
41
- end
42
-
43
- def unavailable_extensions
44
- return @unavailable_extensions if defined?(@unavailable_extensions)
45
-
46
- enabled_extensions = ActiveRecord::Base.connection.extensions
47
- @unavailable_extensions = REQUIRED_EXTENSIONS.delete_if { |ext| ext.to_s.in?(enabled_extensions) }
48
- end
49
- end
50
- end
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= content_for :title %></title>
5
- <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
6
- </head>
7
- <body class="p-5 text-xs">
8
- <%= yield %>
9
- </body>
10
- </html>
@@ -1,22 +0,0 @@
1
- <h1 class="font-bold text-xl my-5"><%= title %></h1>
2
-
3
- <table class="w-full font-mono border-collapse border border-green-800 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
-
22
- <span class="italic">run_at: <%= Time.now.utc %></span>
@@ -1,48 +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
-
9
- <span id="rails" class="font-mono font-bold p-3 bg-gray-100 cursor-pointer select-none">RAILS</span> <span id="sql" class="font-mono font-normal p-3 bg-gray-50 cursor-pointer select-none">SQL</span>
10
- <pre id="rails_code" class="font-mono p-5 bg-gray-100 block">
11
- <% unavailable_extensions.each do |extension, queries| %>
12
- ActiveRecord::Base.connection.enable_extension "<%= extension %>"
13
- <% end %>
14
- </pre>
15
-
16
- <pre id="sql_code" class="font-mono p-5 bg-gray-100 hidden">
17
- <% unavailable_extensions.each do |extension, queries| %>
18
- CREATE EXTENSION <%= extension %>;
19
- <% end %>
20
- </pre>
21
-
22
- <script>
23
- const rails = document.getElementById('rails')
24
- const sql = document.getElementById('sql')
25
- const railsCode = document.getElementById('rails_code')
26
- const sqlCode = document.getElementById('sql_code')
27
-
28
- rails.addEventListener('click', (e) => {
29
- railsCode.classList.remove('hidden')
30
- sqlCode.classList.add('hidden')
31
-
32
- rails.classList.replace('bg-gray-50','bg-gray-100')
33
- sql.classList.replace('bg-gray-100','bg-gray-50')
34
- rails.classList.replace('font-normal','font-bold')
35
- sql.classList.replace('font-bold','font-normal')
36
- })
37
-
38
- sql.addEventListener('click', (e) => {
39
- railsCode.classList.add('hidden')
40
- sqlCode.classList.remove('hidden')
41
-
42
- rails.classList.replace('bg-gray-100','bg-gray-50')
43
- sql.classList.replace('bg-gray-50','bg-gray-100')
44
- rails.classList.replace('font-bold','font-normal')
45
- sql.classList.replace('font-normal','font-bold')
46
- })
47
- </script>
48
-
@@ -1,4 +0,0 @@
1
- <%= content_for :title, "pg_extras" %>
2
- <%= render "rails_pg_extras_web/shared/queries_selector" %>
3
-
4
- <%= render "unavailable_extensions_warning" if unavailable_extensions.any? %>
@@ -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
- <span class="text-red"><%= @error %></span>
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,5 +0,0 @@
1
- RailsPgExtrasWeb::Engine.routes.draw do
2
- resources :queries, only: [:index]
3
-
4
- root to: "queries#index"
5
- end
@@ -1,5 +0,0 @@
1
- module RailsPgExtrasWeb
2
- class Engine < ::Rails::Engine
3
- isolate_namespace RailsPgExtrasWeb
4
- end
5
- end