blazer 0.0.7 → 0.0.8

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: 67ee6e1cfb35a8d4629d04a7628f5ed381aa6404
4
- data.tar.gz: 1d678a64b0674a896d7fb55a972707fdff578f47
3
+ metadata.gz: 58310083acc765c7f14b7c361d6dd5c845aa37f4
4
+ data.tar.gz: 32cee84631c9ac472909833eae6eb8ad4a911e50
5
5
  SHA512:
6
- metadata.gz: 6f53f4290b16da1acd024ed52e310ee664badc3fe5d88e78d441b4283b799e96eb17080d31245d75b194cc3baa4958da6672323115abb23c70efe8be6f96572a
7
- data.tar.gz: 254440602381a960167d8697d041a412d3c5c01674935abd33cd78a7bbfce0b6c6e21d48973375af35df8d48eadfb9b3241545ab392a4edf00f21b5e267aae56
6
+ metadata.gz: 568ecb2c3426f3656221de13be4d00584de68148767b1dd02f2b7534aa1400110a2e0ecdbbd5df0ba85c4f761c21febd8bd12fe58fb69f3484c052afc323b393
7
+ data.tar.gz: 65d08be78a40077860e6ecdafc9182c4cf35eb61aebf22817932669fccc012a3df502321f569d4f049f1f1827ad158c93dae4c184a34b93ec23e6246ed529a31
@@ -1,3 +1,9 @@
1
+ ## 0.0.8
2
+
3
+ - Easier to edit queries with variables
4
+ - Dynamically expand editor height as needed
5
+ - No need for spaces in search
6
+
1
7
  ## 0.0.7
2
8
 
3
9
  - Fixed error when no `User` class
@@ -29,7 +29,7 @@ module Blazer
29
29
  @query.creator = current_user if respond_to?(:current_user) && Blazer.user_class
30
30
 
31
31
  if @query.save
32
- redirect_to @query
32
+ redirect_to query_path(@query, variable_params)
33
33
  else
34
34
  render :new
35
35
  end
@@ -115,7 +115,7 @@ module Blazer
115
115
 
116
116
  def update
117
117
  if @query.update(query_params)
118
- redirect_to query_path(@query)
118
+ redirect_to query_path(@query, variable_params)
119
119
  else
120
120
  render :edit
121
121
  end
@@ -193,6 +193,11 @@ module Blazer
193
193
  end
194
194
  end
195
195
 
196
+ def variable_params
197
+ params.except(:controller, :action, :id, :host, :query, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement)
198
+ end
199
+ helper_method :variable_params
200
+
196
201
  def settings
197
202
  YAML.load(File.read(Rails.root.join("config", "blazer.yml")))
198
203
  end
@@ -1,5 +1,7 @@
1
1
  module Blazer
2
2
  class Query < ActiveRecord::Base
3
+ belongs_to :creator, class_name: Blazer.user_class.to_s if Blazer.user_class
4
+
3
5
  validates :name, presence: true
4
6
  validates :statement, presence: true
5
7
 
@@ -2,7 +2,7 @@
2
2
  <div class="alert alert-danger"><%= @query.errors.full_messages.first %></div>
3
3
  <% end %>
4
4
 
5
- <%= form_for @query, html: {class: "the_form", autocomplete: "off"} do |f| %>
5
+ <%= form_for @query, url: (@query.persisted? ? query_path(@query, variable_params) : queries_path(variable_params)), html: {class: "the_form", autocomplete: "off"} do |f| %>
6
6
  <div class="row">
7
7
  <div class="col-xs-8">
8
8
  <div class= "form-group">
@@ -61,16 +61,31 @@
61
61
  name: 'run',
62
62
  bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'},
63
63
  exec: function(editor) {
64
- $("#run").click();
64
+ $("#run").click();
65
65
  },
66
66
  readOnly: false // false if this command should not apply in readOnly mode
67
67
  });
68
68
 
69
- editor.resize();
69
+ // http://stackoverflow.com/questions/11584061/
70
+ function adjustHeight() {
71
+ var lines = editor.getSession().getScreenLength();
72
+ if (lines < 9) {
73
+ lines = 9;
74
+ }
75
+
76
+ var newHeight = (lines + 1) * 16;
77
+ $("#editor").height(newHeight.toString() + "px");
78
+ editor.resize();
79
+ };
80
+
81
+ editor.getSession().on("change", adjustHeight);
82
+ adjustHeight();
70
83
  $("#editor").show();
71
84
  editor.focus();
72
85
 
73
86
  var error_line = null;
87
+ var xhr;
88
+ var params = <%= raw json_escape(variable_params.to_json) %>;
74
89
 
75
90
  $("#run").click(function (e) {
76
91
  e.preventDefault();
@@ -81,7 +96,10 @@
81
96
  }
82
97
 
83
98
  $("#results").html('<p class="text-muted">Loading...</p>');
84
- $.post("<%= run_queries_path %>", {statement: editor.getValue()}, function (data) {
99
+ if (xhr) {
100
+ xhr.abort();
101
+ }
102
+ xhr = $.post("<%= run_queries_path %>", $.extend({}, params, {statement: editor.getValue()}), function (data) {
85
103
  $("#results").html(data);
86
104
 
87
105
  error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
@@ -24,6 +24,7 @@
24
24
  <% if @trending_queries[query.id] %>
25
25
  <small style="font-weight: bold; color: #f60;">TRENDING</small>
26
26
  <% end %>
27
+ <div class="hide"><%= query.name.gsub(/\s+/, "") %></div>
27
28
  </td>
28
29
  <td class="creator text-right text-muted">
29
30
  <% if query.respond_to?(:creator) && (creator = query.creator) && creator.respond_to?(Blazer.user_name) %>
@@ -6,10 +6,13 @@
6
6
  <p class="text-muted"><%= pluralize(@rows.size, "row") %></p>
7
7
  <% if @rows.any? %>
8
8
  <% values = @rows.first.values %>
9
- <% if values.size >= 2 and values.first.is_a?(Time) and values[1..-1].all?{|v| v.is_a?(Numeric) } %>
9
+ <% if values.size >= 2 && values.first.is_a?(Time) && values[1..-1].all?{|v| v.is_a?(Numeric) } %>
10
10
  <% time_k = @columns.keys.first %>
11
11
  <%= line_chart @columns.keys[1..-1].map{|k| {name: k, data: @rows.map{|r| [r[time_k], r[k]] }} } %>
12
- <% elsif values.size == 2 and values.first.is_a?(String) and values.last.is_a?(Numeric) %>
12
+ <% elsif values.size == 3 && values.first.is_a?(Time) && values[1].is_a?(String) && values[2].is_a?(Numeric) %>
13
+ <% keys = @columns.keys %>
14
+ <%= line_chart @rows.group_by { |v| v[keys[1]] }.map { |name, v| {name: name, data: v.map { |v2| [v2[keys[0]], v2[keys[2]]] } } } %>
15
+ <% elsif values.size == 2 && values.first.is_a?(String) && values.last.is_a?(Numeric) %>
13
16
  <%= pie_chart @rows.map(&:values), library: {sliceVisibilityThreshold: 1 / 40.0} %>
14
17
  <% end %>
15
18
 
@@ -10,10 +10,10 @@
10
10
  </h3>
11
11
  </div>
12
12
  <div class="col-sm-3 text-right">
13
- <%= link_to "Edit", edit_query_path(@query), class: "btn btn-default" %>
14
- <%= link_to "Fork", new_query_path(statement: @query.statement), class: "btn btn-info" %>
13
+ <%= link_to "Edit", edit_query_path(@query, variable_params), class: "btn btn-default" %>
14
+ <%= link_to "Fork", new_query_path(variable_params.merge(statement: @query.statement)), class: "btn btn-info" %>
15
15
 
16
- <% if !@error and @success %>
16
+ <% if !@error && @success %>
17
17
  <%= button_to "Download", run_queries_path(statement: @statement, query_id: @query.id, format: "csv"), class: "btn btn-primary" %>
18
18
  <% end %>
19
19
  </div>
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
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: 0.0.7
4
+ version: 0.0.8
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-07-24 00:00:00.000000000 Z
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails