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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 135fd38b9d7a75473a1ecf2afd1acf27ff9a6ffb
4
- data.tar.gz: 83e0ec15e78191d00b6a81275f60c59dfaff17d8
3
+ metadata.gz: 2abc84ccb66e4bc713b59739c5ecbed82411375c
4
+ data.tar.gz: 821d99ac43d210bf09a1bf63ce7cf82701e57acf
5
5
  SHA512:
6
- metadata.gz: 11fd0afc742cde141f2019cc70de520a95b7222c302dba952807dd91945380db9aeb2334e89eaa7a8f60ebcbfb9ec56faf838a23e12f7a80b9507f1937942aa3
7
- data.tar.gz: ac2b8e150d3791aa89d63be8562d6413c30cbd488d5b0dad7a60c813e66ece451adec26b6b2962708ad322495a52c02dd612933769bf14b54d4c4a87612b81de
6
+ metadata.gz: e4945e0f6fb08913aaa5b3e3b6f9d9244a6408a5e094deff5fb384ecc2745d30eeb943ad7b827de8e3d4ee53035d0c16d58e9fe52b910a219c0739c19605c4ec
7
+ data.tar.gz: 8eb0e8f3a2b6e155fd9c45c63cbe8a5e176bd45e2dc5c83db60ceb716d2a0cf8da2a368cd13ea15ed255507a5fb6a713b972462bc27745b4aefa12f375424b23
@@ -1,3 +1,8 @@
1
+ ## 1.0.2
2
+
3
+ - Fixed error when installing
4
+ - Added `schemas` option
5
+
1
6
  ## 1.0.1
2
7
 
3
8
  - Added comments to queries
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](http://blazer.hero2app.com)
5
+ [Try it out](https://blazerme.herokuapp.com)
6
6
 
7
- [![Screenshot](http://blazer.hero2app.com/assets/screenshot-473b2307ebaf7377645079cbf2badf73.png)](http://blazer.hero2app.com)
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](http://blazer.hero2app.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)
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](http://blazer.hero2app.com/queries/9-movies-by-genre)
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](http://blazer.hero2app.com/queries/4-highest-rated-movies) - title column
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](http://blazer.hero2app.com/queries/11-users) - occupation_id column
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](http://blazer.hero2app.com/queries/1-new-ratings-per-week)
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](http://blazer.hero2app.com/queries/7-new-ratings-by-gender-per-month)
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](http://blazer.hero2app.com/queries/2-top-genres)
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](http://blazer.hero2app.com/dashboards/1-movielens)
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](http://blazer.hero2app.com/checks)
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: 15 # applies to PostgreSQL only
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 rows.map { |v| v.values.reverse }
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
- Cached <%= time_ago_in_words(@cached_at, include_seconds: true) %> ago
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 %>
@@ -142,6 +142,8 @@
142
142
  }
143
143
  </script>
144
144
  <% end %>
145
+
146
+ <input type="submit" class="btn btn-success" value="Run" style="vertical-align: top;" />
145
147
  </form>
146
148
  <% end %>
147
149
 
@@ -23,7 +23,14 @@ module Blazer
23
23
  end
24
24
 
25
25
  def self.settings
26
- @settings ||= YAML.load(ERB.new(File.read(Rails.root.join("config", "blazer.yml"))).result)
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
@@ -99,10 +99,13 @@ module Blazer
99
99
  ["blazer", "v2", id, Digest::MD5.hexdigest(statement)].join("/")
100
100
  end
101
101
 
102
- def tables
102
+ def schemas
103
103
  default_schema = postgresql? ? "public" : connection_model.connection_config[:database]
104
- schema = connection_model.connection_config[:schema] || default_schema
105
- 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 = ?", schema]))
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
 
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
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-08 00:00:00.000000000 Z
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: