pghero 3.8.0 → 4.0.1
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/CHANGELOG.md +21 -0
- data/README.md +3 -2
- data/app/assets/javascripts/pghero/Chart.bundle.js +2228 -5320
- data/app/assets/javascripts/pghero/application.js +104 -68
- data/app/assets/javascripts/pghero/highlight.min.js +330 -341
- data/app/assets/javascripts/pghero/nouislider.js +64 -5
- data/app/assets/stylesheets/pghero/application.css +7 -1
- data/app/controllers/pg_hero/home_controller.rb +71 -37
- data/app/views/layouts/pg_hero/application.html.erb +1 -1
- data/app/views/pg_hero/home/_live_queries_table.html.erb +4 -2
- data/app/views/pg_hero/home/_queries_table.html.erb +8 -7
- data/app/views/pg_hero/home/_query_stats_slider.html.erb +1 -0
- data/app/views/pg_hero/home/_suggested_index.html.erb +3 -3
- data/app/views/pg_hero/home/explain.html.erb +2 -1
- data/app/views/pg_hero/home/index.html.erb +17 -18
- data/app/views/pg_hero/home/index_bloat.html.erb +2 -2
- data/app/views/pg_hero/home/live_queries.html.erb +7 -3
- data/app/views/pg_hero/home/queries.html.erb +31 -6
- data/app/views/pg_hero/home/show_query.html.erb +5 -5
- data/app/views/pg_hero/home/space.html.erb +5 -4
- data/app/views/pg_hero/home/tune.html.erb +1 -1
- data/lib/generators/pghero/templates/config.yml.tt +6 -1
- data/lib/generators/pghero/templates/query_stats.rb.tt +7 -1
- data/lib/generators/pghero/templates/upgrade_query_stats.rb.tt +23 -0
- data/lib/generators/pghero/upgrade_query_stats_generator.rb +19 -0
- data/lib/pghero/database.rb +6 -9
- data/lib/pghero/engine.rb +3 -10
- data/lib/pghero/methods/basic.rb +28 -27
- data/lib/pghero/methods/connections.rb +16 -32
- data/lib/pghero/methods/explain.rb +13 -20
- data/lib/pghero/methods/indexes.rb +8 -5
- data/lib/pghero/methods/kill.rb +4 -1
- data/lib/pghero/methods/maintenance.rb +14 -20
- data/lib/pghero/methods/queries.rb +7 -5
- data/lib/pghero/methods/query_stats.rb +264 -238
- data/lib/pghero/methods/replication.rb +9 -20
- data/lib/pghero/methods/sequences.rb +40 -18
- data/lib/pghero/methods/settings.rb +1 -20
- data/lib/pghero/methods/space.rb +11 -8
- data/lib/pghero/methods/suggested_indexes.rb +15 -16
- data/lib/pghero/methods/system.rb +6 -106
- data/lib/pghero/methods/tables.rb +7 -3
- data/lib/pghero/query.rb +8 -0
- data/lib/pghero/query_stats.rb +3 -0
- data/lib/pghero/version.rb +1 -1
- data/lib/pghero.rb +10 -42
- data/licenses/LICENSE-chart.js.txt +1 -1
- metadata +5 -5
- data/app/assets/javascripts/pghero/jquery.js +0 -10993
- data/lib/pghero/methods/users.rb +0 -95
- data/licenses/LICENSE-jquery.txt +0 -20
data/lib/pghero/methods/users.rb
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
module PgHero
|
|
2
|
-
module Methods
|
|
3
|
-
module Users
|
|
4
|
-
# documented as unsafe to pass user input
|
|
5
|
-
# identifiers are now quoted, but still not officially supported
|
|
6
|
-
def create_user(user, password: nil, schema: "public", database: nil, readonly: false, tables: nil)
|
|
7
|
-
password ||= random_password
|
|
8
|
-
database ||= PgHero.connection_config(connection_model)[:database]
|
|
9
|
-
|
|
10
|
-
user = quote_ident(user)
|
|
11
|
-
schema = quote_ident(schema)
|
|
12
|
-
database = quote_ident(database)
|
|
13
|
-
|
|
14
|
-
commands =
|
|
15
|
-
[
|
|
16
|
-
"CREATE ROLE #{user} LOGIN PASSWORD #{quote(password)}",
|
|
17
|
-
"GRANT CONNECT ON DATABASE #{database} TO #{user}",
|
|
18
|
-
"GRANT USAGE ON SCHEMA #{schema} TO #{user}"
|
|
19
|
-
]
|
|
20
|
-
if readonly
|
|
21
|
-
if tables
|
|
22
|
-
commands.concat table_grant_commands("SELECT", tables, user)
|
|
23
|
-
else
|
|
24
|
-
commands << "GRANT SELECT ON ALL TABLES IN SCHEMA #{schema} TO #{user}"
|
|
25
|
-
commands << "ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT SELECT ON TABLES TO #{user}"
|
|
26
|
-
end
|
|
27
|
-
else
|
|
28
|
-
if tables
|
|
29
|
-
commands.concat table_grant_commands("ALL PRIVILEGES", tables, user)
|
|
30
|
-
else
|
|
31
|
-
commands << "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{schema} TO #{user}"
|
|
32
|
-
commands << "GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA #{schema} TO #{user}"
|
|
33
|
-
commands << "ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT ALL PRIVILEGES ON TABLES TO #{user}"
|
|
34
|
-
commands << "ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} GRANT ALL PRIVILEGES ON SEQUENCES TO #{user}"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# run commands
|
|
39
|
-
connection_model.transaction do
|
|
40
|
-
commands.each do |command|
|
|
41
|
-
execute command
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
{password: password}
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# documented as unsafe to pass user input
|
|
49
|
-
# identifiers are now quoted, but still not officially supported
|
|
50
|
-
def drop_user(user, schema: "public", database: nil)
|
|
51
|
-
database ||= PgHero.connection_config(connection_model)[:database]
|
|
52
|
-
|
|
53
|
-
user = quote_ident(user)
|
|
54
|
-
schema = quote_ident(schema)
|
|
55
|
-
database = quote_ident(database)
|
|
56
|
-
|
|
57
|
-
# thanks shiftb
|
|
58
|
-
commands =
|
|
59
|
-
[
|
|
60
|
-
"REVOKE CONNECT ON DATABASE #{database} FROM #{user}",
|
|
61
|
-
"REVOKE USAGE ON SCHEMA #{schema} FROM #{user}",
|
|
62
|
-
"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{schema} FROM #{user}",
|
|
63
|
-
"REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA #{schema} FROM #{user}",
|
|
64
|
-
"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE SELECT ON TABLES FROM #{user}",
|
|
65
|
-
"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE SELECT ON SEQUENCES FROM #{user}",
|
|
66
|
-
"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE ALL ON SEQUENCES FROM #{user}",
|
|
67
|
-
"ALTER DEFAULT PRIVILEGES IN SCHEMA #{schema} REVOKE ALL ON TABLES FROM #{user}",
|
|
68
|
-
"DROP ROLE #{user}"
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
# run commands
|
|
72
|
-
connection_model.transaction do
|
|
73
|
-
commands.each do |command|
|
|
74
|
-
execute command
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
true
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
def random_password
|
|
84
|
-
require "securerandom"
|
|
85
|
-
SecureRandom.base64(40).delete("+/=")[0...24]
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def table_grant_commands(privilege, tables, quoted_user)
|
|
89
|
-
tables.map do |table|
|
|
90
|
-
"GRANT #{privilege} ON TABLE #{quote_ident(table)} TO #{quoted_user}"
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
data/licenses/LICENSE-jquery.txt
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|