blazer 1.0.1 → 1.0.2
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/CHANGELOG.md +5 -0
- data/README.md +38 -12
- data/app/controllers/blazer/dashboards_controller.rb +1 -1
- data/app/views/blazer/queries/run.html.erb +7 -2
- data/app/views/blazer/queries/show.html.erb +2 -0
- data/lib/blazer.rb +8 -1
- data/lib/blazer/data_source.rb +6 -3
- data/lib/blazer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2abc84ccb66e4bc713b59739c5ecbed82411375c
|
4
|
+
data.tar.gz: 821d99ac43d210bf09a1bf63ce7cf82701e57acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4945e0f6fb08913aaa5b3e3b6f9d9244a6408a5e094deff5fb384ecc2745d30eeb943ad7b827de8e3d4ee53035d0c16d58e9fe52b910a219c0739c19605c4ec
|
7
|
+
data.tar.gz: 8eb0e8f3a2b6e155fd9c45c63cbe8a5e176bd45e2dc5c83db60ceb716d2a0cf8da2a368cd13ea15ed255507a5fb6a713b972462bc27745b4aefa12f375424b23
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Explore your data with SQL. Easily create charts and dashboards, and share them with your team.
|
4
4
|
|
5
|
-
[Try it out](
|
5
|
+
[Try it out](https://blazerme.herokuapp.com)
|
6
6
|
|
7
|
-
[![Screenshot](
|
7
|
+
[![Screenshot](https://blazerme.herokuapp.com/assets/screenshot-18d79092e635b4b220f57ff7a1ecea41.png)](https://blazerme.herokuapp.com)
|
8
8
|
|
9
9
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
10
10
|
|
@@ -135,7 +135,7 @@ Create queries with variables.
|
|
135
135
|
SELECT * FROM users WHERE gender = {gender}
|
136
136
|
```
|
137
137
|
|
138
|
-
Use `{start_time}` and `{end_time}` for time ranges. [Example](
|
138
|
+
Use `{start_time}` and `{end_time}` for time ranges. [Example](https://blazerme.herokuapp.com/queries/8-ratings-by-time-range?start_time=1997-10-03T05%3A00%3A00%2B00%3A00&end_time=1997-10-04T04%3A59%3A59%2B00%3A00)
|
139
139
|
|
140
140
|
```sql
|
141
141
|
SELECT * FROM ratings WHERE rated_at >= {start_time} AND rated_at <= {end_time}
|
@@ -143,7 +143,7 @@ SELECT * FROM ratings WHERE rated_at >= {start_time} AND rated_at <= {end_time}
|
|
143
143
|
|
144
144
|
### Smart Variables
|
145
145
|
|
146
|
-
[Example](
|
146
|
+
[Example](https://blazerme.herokuapp.com/queries/9-movies-by-genre)
|
147
147
|
|
148
148
|
Suppose you have the query:
|
149
149
|
|
@@ -164,7 +164,7 @@ The first column is the value of the variable, and the second column is the labe
|
|
164
164
|
|
165
165
|
### Linked Columns
|
166
166
|
|
167
|
-
[Example](
|
167
|
+
[Example](https://blazerme.herokuapp.com/queries/4-highest-rated-movies) - title column
|
168
168
|
|
169
169
|
Link results to other pages in your apps or around the web. Specify a column name and where it should link to. You can use the value of the result with `{value}`.
|
170
170
|
|
@@ -176,7 +176,7 @@ linked_columns:
|
|
176
176
|
|
177
177
|
### Smart Columns
|
178
178
|
|
179
|
-
[Example](
|
179
|
+
[Example](https://blazerme.herokuapp.com/queries/11-users) - occupation_id column
|
180
180
|
|
181
181
|
Suppose you have the query:
|
182
182
|
|
@@ -191,6 +191,16 @@ smart_columns:
|
|
191
191
|
city_id: "SELECT id, name FROM cities WHERE id IN {value}"
|
192
192
|
```
|
193
193
|
|
194
|
+
### Caching
|
195
|
+
|
196
|
+
Blazer can automatically cache results to improve speed.
|
197
|
+
|
198
|
+
```yml
|
199
|
+
cache: 60 # minutes
|
200
|
+
```
|
201
|
+
|
202
|
+
Of course, you can force a refresh at any time.
|
203
|
+
|
194
204
|
## Charts
|
195
205
|
|
196
206
|
Blazer will automatically generate charts based on the types of the columns returned in your query.
|
@@ -199,13 +209,13 @@ Blazer will automatically generate charts based on the types of the columns retu
|
|
199
209
|
|
200
210
|
There are two ways to generate line charts.
|
201
211
|
|
202
|
-
2+ columns - timestamp, numeric(s) - [Example](
|
212
|
+
2+ columns - timestamp, numeric(s) - [Example](https://blazerme.herokuapp.com/queries/1-new-ratings-per-week)
|
203
213
|
|
204
214
|
```sql
|
205
215
|
SELECT date_trunc('week', created_at), COUNT(*) FROM users GROUP BY 1
|
206
216
|
```
|
207
217
|
|
208
|
-
3 columns - timestamp, string, numeric - [Example](
|
218
|
+
3 columns - timestamp, string, numeric - [Example](https://blazerme.herokuapp.com/queries/7-new-ratings-by-gender-per-month)
|
209
219
|
|
210
220
|
|
211
221
|
```sql
|
@@ -214,7 +224,7 @@ SELECT date_trunc('week', created_at), gender, COUNT(*) FROM users GROUP BY 1, 2
|
|
214
224
|
|
215
225
|
### Pie Chart
|
216
226
|
|
217
|
-
2 columns - string, numeric - [Example](
|
227
|
+
2 columns - string, numeric - [Example](https://blazerme.herokuapp.com/queries/2-top-genres)
|
218
228
|
|
219
229
|
```sql
|
220
230
|
SELECT gender, COUNT(*) FROM users GROUP BY 1
|
@@ -222,7 +232,7 @@ SELECT gender, COUNT(*) FROM users GROUP BY 1
|
|
222
232
|
|
223
233
|
## Dashboards
|
224
234
|
|
225
|
-
Create a dashboard with multiple queries. [Example](
|
235
|
+
Create a dashboard with multiple queries. [Example](https://blazerme.herokuapp.com/dashboards/1-movielens)
|
226
236
|
|
227
237
|
If the query has a chart, the chart is shown. Otherwise, you’ll see a table.
|
228
238
|
|
@@ -230,7 +240,7 @@ If any queries have variables, they will show up on the dashboard.
|
|
230
240
|
|
231
241
|
## Checks
|
232
242
|
|
233
|
-
Checks give you a centralized place to see the health of your data. [Example](
|
243
|
+
Checks give you a centralized place to see the health of your data. [Example](https://blazerme.herokuapp.com/checks)
|
234
244
|
|
235
245
|
Create a query to identify bad rows.
|
236
246
|
|
@@ -341,7 +351,20 @@ data_sources:
|
|
341
351
|
main:
|
342
352
|
url: <%= ENV["BLAZER_DATABASE_URL"] %>
|
343
353
|
|
344
|
-
# timeout
|
354
|
+
# statement timeout, in seconds
|
355
|
+
# applies to PostgreSQL only
|
356
|
+
# none by default
|
357
|
+
# timeout: 15
|
358
|
+
|
359
|
+
# time to cache results, in minutes
|
360
|
+
# can greatly improve speed
|
361
|
+
# none by default
|
362
|
+
# cache: 60
|
363
|
+
|
364
|
+
# wrap queries in a transaction for safety
|
365
|
+
# not necessary if you use a read-only user
|
366
|
+
# true by default
|
367
|
+
# use_transaction: false
|
345
368
|
|
346
369
|
smart_variables:
|
347
370
|
# zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
|
@@ -363,6 +386,9 @@ audit: true
|
|
363
386
|
|
364
387
|
# method name for the user model
|
365
388
|
# user_name: name
|
389
|
+
|
390
|
+
# email to send checks from
|
391
|
+
# from_email: blazer@example.org
|
366
392
|
```
|
367
393
|
|
368
394
|
## TODO
|
@@ -35,7 +35,7 @@ module Blazer
|
|
35
35
|
query = data_source.smart_variables[var]
|
36
36
|
if query
|
37
37
|
rows, error, cached_at = data_source.run_statement(query)
|
38
|
-
(@smart_vars[var] ||= []).concat
|
38
|
+
((@smart_vars[var] ||= []).concat(rows.map { |v| v.values.reverse })).uniq!
|
39
39
|
@sql_errors << error if error
|
40
40
|
end
|
41
41
|
end
|
@@ -8,9 +8,14 @@
|
|
8
8
|
<% end %>
|
9
9
|
<% else %>
|
10
10
|
<% unless @only_chart %>
|
11
|
-
<% if @cached_at %>
|
11
|
+
<% if @cached_at || @data_source.cache %>
|
12
12
|
<p class="text-muted" style="float: right;">
|
13
|
-
|
13
|
+
<% if @cached_at %>
|
14
|
+
Cached <%= time_ago_in_words(@cached_at, include_seconds: true) %> ago
|
15
|
+
<% elsif !params[:data_source] %>
|
16
|
+
Cached just now
|
17
|
+
<% end %>
|
18
|
+
|
14
19
|
<% if @query && !params[:data_source] %>
|
15
20
|
<%= link_to "Refresh", refresh_query_path(@query, variable_params), method: :post %>
|
16
21
|
<% end %>
|
data/lib/blazer.rb
CHANGED
@@ -23,7 +23,14 @@ module Blazer
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.settings
|
26
|
-
@settings ||=
|
26
|
+
@settings ||= begin
|
27
|
+
path = Rails.root.join("config", "blazer.yml").to_s
|
28
|
+
if File.exist?(path)
|
29
|
+
YAML.load(ERB.new(File.read(path)).result)
|
30
|
+
else
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
def self.data_sources
|
data/lib/blazer/data_source.rb
CHANGED
@@ -99,10 +99,13 @@ module Blazer
|
|
99
99
|
["blazer", "v2", id, Digest::MD5.hexdigest(statement)].join("/")
|
100
100
|
end
|
101
101
|
|
102
|
-
def
|
102
|
+
def schemas
|
103
103
|
default_schema = postgresql? ? "public" : connection_model.connection_config[:database]
|
104
|
-
|
105
|
-
|
104
|
+
settings["schemas"] || [connection_model.connection_config[:schema] || default_schema]
|
105
|
+
end
|
106
|
+
|
107
|
+
def tables
|
108
|
+
rows, error, cached_at = run_statement(connection_model.send(:sanitize_sql_array, ["SELECT table_name, column_name, ordinal_position, data_type FROM information_schema.columns WHERE table_schema IN (?)", schemas]))
|
106
109
|
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 }]
|
107
110
|
end
|
108
111
|
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -171,3 +171,4 @@ signing_key:
|
|
171
171
|
specification_version: 4
|
172
172
|
summary: Share data effortlessly with your team
|
173
173
|
test_files: []
|
174
|
+
has_rdoc:
|