blazer 1.0.3 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c76491b2936f131b04b198dbd1a36a0e10ba0500
4
- data.tar.gz: 5cbfff8d2d610da3ed0352328b05de7e8a04bb16
3
+ metadata.gz: 51e43730bc19587ab66d3136921b7c630fe623ba
4
+ data.tar.gz: 16e489763b19ffd3cc8cb8965215c83665faab8f
5
5
  SHA512:
6
- metadata.gz: 1b2e877250e2f1088e34ed5f541b25c133ed2b8ec4b6fac34e468ea233a90a4d4b96568d4cd599de4f4d701578a2eeef21c68d13c3143d331a3bf0d7180cea32
7
- data.tar.gz: 1aea7e790bd9c65b66ebd2e9d93a7b427ebe50140832e9e8cb6b7d7057e81b7ca7a7e7e2955bb6ed44ecf59f8427761c9d4a15a9b1bcc465812539c4c2c7a58d
6
+ metadata.gz: 9758237b705407208a9264f35d4e33debb43611759d5827ae36305a4ee8789e0538506554319b7cfb739947eb91d53655f25ecf9bc73639c4b44c2a01a3a33ef
7
+ data.tar.gz: 2f6a6e50e22f9cd4963782ae7ef54efb89f2310892bccb0d5949c4060d0459d818a43d38d6ce8b519c5fec3629082a35b3c9aec33a8e802deb91b24f5cf0d516
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.4
2
+
3
+ - Added recently viewed queries and dashboards to home page
4
+ - Fixed refresh when transform statement is used
5
+ - Fixed error when no user model
6
+
1
7
  ## 1.0.3
2
8
 
3
9
  - Added maps
data/README.md CHANGED
@@ -10,6 +10,8 @@ Explore your data with SQL. Easily create charts and dashboards, and share them
10
10
 
11
11
  **Blazer 1.0 was recently released!** See the [instructions for upgrading](#10).
12
12
 
13
+ :envelope: [Subscribe to releases](https://libraries.io/rubygems/blazer)
14
+
13
15
  ## Features
14
16
 
15
17
  - **Multiple data sources** - works with PostgreSQL, MySQL, and Redshift
@@ -232,7 +234,7 @@ SELECT gender, COUNT(*) FROM users GROUP BY 1
232
234
 
233
235
  ### Maps
234
236
 
235
- Columns named `latitude` and `longitude` or `lat` and `lon`.
237
+ Columns named `latitude` and `longitude` or `lat` and `lon` - [Example](https://blazerme.herokuapp.com/queries/11-airports-in-pacific-time-zone)
236
238
 
237
239
  ```sql
238
240
  SELECT name, latitude, longtitude FROM cities
@@ -83,3 +83,7 @@ input.search:focus {
83
83
  overflow: scroll;
84
84
  text-align: left;
85
85
  }
86
+
87
+ .dashboard a {
88
+ font-weight: bold;
89
+ }
@@ -42,7 +42,7 @@ module Blazer
42
42
  helper_method :extract_vars
43
43
 
44
44
  def variable_params
45
- params.except(:controller, :action, :id, :host, :query, :query_id, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement, :data_source)
45
+ params.except(:controller, :action, :id, :host, :query, :query_id, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement, :data_source, :name)
46
46
  end
47
47
  helper_method :variable_params
48
48
 
@@ -1,23 +1,27 @@
1
1
  module Blazer
2
2
  class QueriesController < BaseController
3
- before_action :set_queries, only: [:home, :index]
4
3
  before_action :set_query, only: [:show, :edit, :update, :destroy, :refresh]
5
4
 
6
5
  def home
7
- @queries = @queries.limit(1000)
6
+ set_queries(1000)
8
7
  end
9
8
 
10
9
  def index
10
+ set_queries
11
11
  render partial: "index", layout: false
12
12
  end
13
13
 
14
14
  def new
15
- @query = Blazer::Query.new(statement: params[:statement], data_source: params[:data_source])
15
+ @query = Blazer::Query.new(
16
+ statement: params[:statement],
17
+ data_source: params[:data_source],
18
+ name: params[:name]
19
+ )
16
20
  end
17
21
 
18
22
  def create
19
23
  @query = Blazer::Query.new(query_params)
20
- @query.creator = blazer_user
24
+ @query.creator = blazer_user if @query.respond_to?(:creator)
21
25
 
22
26
  if @query.save
23
27
  redirect_to query_path(@query, variable_params)
@@ -140,6 +144,7 @@ module Blazer
140
144
  data_source = Blazer.data_sources[@query.data_source]
141
145
  @statement = @query.statement.dup
142
146
  process_vars(@statement)
147
+ Blazer.transform_statement.call(data_source, @statement) if Blazer.transform_statement
143
148
  data_source.clear_cache(@statement)
144
149
  redirect_to query_path(@query, variable_params)
145
150
  end
@@ -164,11 +169,23 @@ module Blazer
164
169
 
165
170
  private
166
171
 
167
- def set_queries
172
+ def set_queries(limit = nil)
173
+ @my_queries =
174
+ if blazer_user
175
+ recent_query_ids = Blazer::Audit.where(user_id: blazer_user.id).where("query_id IS NOT NULL").order("created_at desc").limit(100).pluck(:query_id).uniq.first(20)
176
+ queries = Blazer::Query.where(id: recent_query_ids).index_by(&:id)
177
+ recent_query_ids.map { |query_id| queries[query_id] }.compact
178
+ else
179
+ []
180
+ end
181
+
168
182
  @queries = Blazer::Query.order(:name)
183
+ @queries = @queries.where("id NOT IN (?)", @my_queries.map(&:id)) if @my_queries.any?
169
184
  @queries = @queries.includes(:creator) if Blazer.user_class
185
+ @queries = @queries.limit(limit) if limit
170
186
  @trending_queries = Blazer::Audit.group(:query_id).where("created_at > ?", 2.days.ago).having("COUNT(DISTINCT user_id) >= 3").uniq.count(:user_id)
171
187
  @checks = Blazer::Check.group(:query_id).count
188
+ @dashboards = Blazer::Dashboard.order(:name)
172
189
  end
173
190
 
174
191
  def set_query
@@ -3,6 +3,7 @@ module Blazer
3
3
  belongs_to :creator, class_name: Blazer.user_class.to_s if Blazer.user_class
4
4
  has_many :checks, dependent: :destroy
5
5
  has_many :dashboard_queries, dependent: :destroy
6
+ has_many :audits
6
7
 
7
8
  validates :name, presence: true
8
9
  validates :statement, presence: true
@@ -45,7 +45,7 @@
45
45
  <% if @query.persisted? %>
46
46
  <%= link_to "Delete", query_path(@query), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %>
47
47
  <% end %>
48
- <%= f.submit "Save", class: "btn btn-success" %>
48
+ <%= f.submit @query.persisted? ? "Update" : "Create", class: "btn btn-success" %>
49
49
  </div>
50
50
  </div>
51
51
  </div>
@@ -1,18 +1,21 @@
1
- <% @queries.each do |query| %>
1
+ <% (@my_queries + @dashboards + @queries).each do |query| %>
2
+ <% is_query = query.is_a?(Blazer::Query) %>
2
3
  <tr>
3
- <td class="query">
4
+ <td class="query <%= "dashboard" unless is_query %>">
4
5
  <%= link_to query.name, query %>
5
- <span style="color: #ccc;"><%= extract_vars(query.statement).join(", ") %></span>
6
- <% if @queries.size < 1000 && query.created_at > 2.days.ago %>
7
- <small style="font-weight: bold; color: #5cb85c;">NEW</small>
8
- <% end %>
9
- <% if @trending_queries[query.id] %>
10
- <small style="font-weight: bold; color: #f60;">TRENDING</small>
11
- <% end %>
12
- <% if @checks[query.id] %>
13
- <small style="font-weight: bold; color: #f60;">CHECK</small>
6
+ <% if is_query %>
7
+ <span style="color: #ccc;"><%= extract_vars(query.statement).join(", ") %></span>
8
+ <% if @queries.size < 1000 && query.created_at > 2.days.ago %>
9
+ <small style="font-weight: bold; color: #5cb85c;">NEW</small>
10
+ <% end %>
11
+ <% if @trending_queries[query.id] %>
12
+ <small style="font-weight: bold; color: #f60;">TRENDING</small>
13
+ <% end %>
14
+ <% if @checks[query.id] %>
15
+ <small style="font-weight: bold; color: #f60;">CHECK</small>
16
+ <% end %>
17
+ <div class="hide"><%= query.name.gsub(/\s+/, "") %></div>
14
18
  <% end %>
15
- <div class="hide"><%= query.name.gsub(/\s+/, "") %></div>
16
19
  </td>
17
20
  <td class="creator text-right text-muted">
18
21
  <% if query.respond_to?(:creator) && (creator = query.creator) && creator.respond_to?(Blazer.user_name) %>
@@ -20,7 +20,7 @@
20
20
  <table class="table">
21
21
  <thead>
22
22
  <tr>
23
- <th>Query</th>
23
+ <th>Name</th>
24
24
  <th style="width: 20%; text-align: right;">Mastermind</th>
25
25
  </tr>
26
26
  </thead>
@@ -26,15 +26,7 @@
26
26
  <% if @rows.any? %>
27
27
  <% values = @rows.first.values %>
28
28
  <% chart_id = SecureRandom.hex %>
29
- <% if values.size >= 2 && (values.first.is_a?(Time) || values.first.is_a?(Date)) && values[1..-1].all?{|v| v.is_a?(Numeric) } %>
30
- <% time_k = @columns.keys.first %>
31
- <%= line_chart @columns.keys[1..-1].map{|k| {name: k, data: @rows.map{|r| [r[time_k], r[k]] }} }, id: chart_id, min: nil %>
32
- <% elsif values.size == 3 && (values.first.is_a?(Time) || values.first.is_a?(Date)) && values[1].is_a?(String) && values[2].is_a?(Numeric) %>
33
- <% keys = @columns.keys %>
34
- <%= line_chart @rows.group_by { |v| v[keys[1]] }.map { |name, v| {name: name, data: v.map { |v2| [v2[keys[0]], v2[keys[2]]] } } }, id: chart_id, min: nil %>
35
- <% elsif values.size == 2 && values.first.is_a?(String) && values.last.is_a?(Numeric) %>
36
- <%= pie_chart @rows.map(&:values), library: {sliceVisibilityThreshold: 1 / 40.0}, id: chart_id %>
37
- <% elsif blazer_maps? && @markers.any? %>
29
+ <% if blazer_maps? && @markers.any? %>
38
30
  <div id="map" style="height: <%= @only_chart ? 300 : 500 %>px;"></div>
39
31
  <script>
40
32
  L.mapbox.accessToken = '<%= ENV["MAPBOX_ACCESS_TOKEN"] %>';
@@ -56,13 +48,21 @@
56
48
  properties: {
57
49
  description: marker.title,
58
50
  'marker-color': '#f86767',
59
- 'marker-symbol': 'star'
51
+ 'marker-size': 'medium'
60
52
  }
61
53
  });
62
54
  }
63
55
  featureLayer.setGeoJSON(geojson);
64
56
  map.fitBounds(featureLayer.getBounds());
65
57
  </script>
58
+ <% elsif values.size >= 2 && (values.first.is_a?(Time) || values.first.is_a?(Date)) && values[1..-1].all?{|v| v.is_a?(Numeric) } %>
59
+ <% time_k = @columns.keys.first %>
60
+ <%= line_chart @columns.keys[1..-1].map{|k| {name: k, data: @rows.map{|r| [r[time_k], r[k]] }} }, id: chart_id, min: nil %>
61
+ <% elsif values.size == 3 && (values.first.is_a?(Time) || values.first.is_a?(Date)) && values[1].is_a?(String) && values[2].is_a?(Numeric) %>
62
+ <% keys = @columns.keys %>
63
+ <%= line_chart @rows.group_by { |v| v[keys[1]] }.map { |name, v| {name: name, data: v.map { |v2| [v2[keys[0]], v2[keys[2]]] } } }, id: chart_id, min: nil %>
64
+ <% elsif values.size == 2 && values.first.is_a?(String) && values.last.is_a?(Numeric) %>
65
+ <%= pie_chart @rows.map(&:values), library: {sliceVisibilityThreshold: 1 / 40.0}, id: chart_id %>
66
66
  <% elsif @only_chart %>
67
67
  <% if @rows.size == 1 && @rows.first.size == 1 %>
68
68
  <p style="font-size: 160px;"><%= blazer_format_value(@rows.first.keys.first, @rows.first.values.first) %></p>
@@ -25,7 +25,7 @@
25
25
  </div>
26
26
  <div class="col-sm-3 text-right">
27
27
  <%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default" %>
28
- <%= link_to "Fork", new_query_path(variable_params.merge(statement: @query.statement, data_source: @query.data_source)), class: "btn btn-info" %>
28
+ <%= link_to "Fork", new_query_path(variable_params.merge(statement: @query.statement, data_source: @query.data_source, name: "Fork of #{@query.name}")), class: "btn btn-info" %>
29
29
 
30
30
  <% if !@error && @success %>
31
31
  <%= button_to "Download", run_queries_path(statement: @statement, query_id: @query.id, format: "csv"), class: "btn btn-primary" %>
data/lib/blazer/engine.rb CHANGED
@@ -11,7 +11,7 @@ module Blazer
11
11
  Blazer.user_name = Blazer.settings["user_name"] if Blazer.settings["user_name"]
12
12
  Blazer.from_email = Blazer.settings["from_email"] if Blazer.settings["from_email"]
13
13
 
14
- Blazer.user_class ||= Blazer.settings["user_class"] || User rescue nil
14
+ Blazer.user_class ||= Blazer.settings.key?("user_class") ? Blazer.settings["user_class"] : (User rescue nil)
15
15
  Blazer.user_method = Blazer.settings["user_method"]
16
16
  if Blazer.user_class
17
17
  Blazer.user_method ||= "current_#{Blazer.user_class.to_s.downcase.singularize}"
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
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.3
4
+ version: 1.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: 2015-10-18 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails