blazer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of blazer might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/app/controllers/blazer/queries_controller.rb +6 -1
- data/app/views/blazer/queries/run.html.erb +1 -1
- data/lib/blazer.rb +2 -0
- data/lib/blazer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca85fd2dc2de8770aed8a2ace416337ec0fef91f
|
4
|
+
data.tar.gz: 78bc4c7ddf440c5ebb17e8748249da23e642cd07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fec518b9d9a4ceac5c13e6cd13de553dffe04ed1950ce90d2d1d1e7e52c2ad9ad1a565419bd7fd552558c07209971e2716e9f689c7d7f85f7bc2627bf34e4472
|
7
|
+
data.tar.gz: 30a2cc4e7a9235c7915279f0bd22a0a66f4fb90b4ea6569eaa7c5ab5e345cd4805bce83932694933400cdc20f627f78b05aef258c5992ba5283f7c00e83aef19
|
data/README.md
CHANGED
@@ -18,6 +18,7 @@ Works with PostgreSQL and MySQL
|
|
18
18
|
- **Smart Columns** - get the data your want without all the joins
|
19
19
|
- **Smart Variables** - no need to remember ids
|
20
20
|
- **Charts** - visualize the data
|
21
|
+
- **Audits** - all queries are tracked
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
@@ -43,7 +44,7 @@ mount Blazer::Engine, at: "blazer"
|
|
43
44
|
For production, specify your database:
|
44
45
|
|
45
46
|
```ruby
|
46
|
-
ENV["BLAZER_DATABASE_URL"]
|
47
|
+
ENV["BLAZER_DATABASE_URL"] = "postgres://user:password@hostname:5432/database_name"
|
47
48
|
```
|
48
49
|
|
49
50
|
It is **highly, highly recommended** to use a read only user. Keep reading to see how to create one.
|
@@ -59,6 +60,8 @@ BEGIN;
|
|
59
60
|
CREATE ROLE blazer LOGIN PASSWORD 'secret123';
|
60
61
|
GRANT CONNECT ON DATABASE database_name TO blazer;
|
61
62
|
GRANT USAGE ON SCHEMA public TO blazer;
|
63
|
+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO blazer;
|
64
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
|
62
65
|
COMMIT;
|
63
66
|
```
|
64
67
|
|
@@ -104,6 +107,12 @@ Change time zone
|
|
104
107
|
Blazer.time_zone = "Pacific Time (US & Canada)"
|
105
108
|
```
|
106
109
|
|
110
|
+
Change timeout *PostgreSQL only* [master]
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
Blazer.timeout = 10 # defaults to 15
|
114
|
+
```
|
115
|
+
|
107
116
|
Turn off audits
|
108
117
|
|
109
118
|
```ruby
|
@@ -155,6 +155,7 @@ module Blazer
|
|
155
155
|
error = nil
|
156
156
|
begin
|
157
157
|
Blazer::Connection.transaction do
|
158
|
+
Blazer::Connection.connection.execute("SET statement_timeout = #{Blazer.timeout * 1000}") if Blazer.timeout && postgresql?
|
158
159
|
result = Blazer::Connection.connection.select_all(statement)
|
159
160
|
result.each do |untyped_row|
|
160
161
|
row = {}
|
@@ -208,12 +209,16 @@ module Blazer
|
|
208
209
|
end
|
209
210
|
|
210
211
|
def tables
|
211
|
-
default_schema =
|
212
|
+
default_schema = postgresql? ? "public" : Blazer::Connection.connection_config[:database]
|
212
213
|
schema = Blazer::Connection.connection_config[:schema] || default_schema
|
213
214
|
rows, error = run_statement(Blazer::Connection.send(:sanitize_sql_array, ["SELECT table_name, column_name, ordinal_position, data_type FROM information_schema.columns WHERE table_schema = ?", schema]))
|
214
215
|
Hash[ rows.group_by{|r| r["table_name"] }.map{|t, f| [t, f.sort_by{|f| f["ordinal_position"] }.map{|f| f.slice("column_name", "data_type") }] }.sort_by{|t, f| t } ]
|
215
216
|
end
|
216
217
|
helper_method :tables
|
217
218
|
|
219
|
+
def postgresql?
|
220
|
+
Blazer::Connection.connection.adapter_name == "PostgreSQL"
|
221
|
+
end
|
222
|
+
|
218
223
|
end
|
219
224
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<% if @error %>
|
2
2
|
<div class="alert alert-danger"><%= @error %></div>
|
3
3
|
<% elsif !@success %>
|
4
|
-
<div class="alert alert-info">Can’t
|
4
|
+
<div class="alert alert-info">Can’t preview queries with variables...yet!</div>
|
5
5
|
<% else %>
|
6
6
|
<p class="text-muted"><%= pluralize(@rows.size, "row") %></p>
|
7
7
|
<% if @rows.any? %>
|
data/lib/blazer.rb
CHANGED
@@ -8,9 +8,11 @@ module Blazer
|
|
8
8
|
attr_accessor :audit
|
9
9
|
attr_reader :time_zone
|
10
10
|
attr_accessor :user_name
|
11
|
+
attr_accessor :timeout
|
11
12
|
end
|
12
13
|
self.audit = true
|
13
14
|
self.user_name = :name
|
15
|
+
self.timeout = 15
|
14
16
|
|
15
17
|
def self.time_zone=(time_zone)
|
16
18
|
@time_zone = time_zone.is_a?(ActiveSupport::TimeZone) ? time_zone : ActiveSupport::TimeZone[time_zone.to_s]
|
data/lib/blazer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blazer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|