blazer 2.6.2 → 2.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -5
- data/app/assets/javascripts/blazer/moment-timezone-with-data.js +333 -332
- data/app/assets/javascripts/blazer/queries.js +12 -1
- data/app/controllers/blazer/queries_controller.rb +3 -2
- data/app/views/blazer/dashboards/show.html.erb +3 -1
- data/app/views/blazer/queries/show.html.erb +2 -2
- data/lib/blazer/adapters/sql_adapter.rb +3 -0
- data/lib/blazer/data_source.rb +3 -3
- data/lib/blazer/run_statement.rb +2 -2
- data/lib/blazer/version.rb +1 -1
- data/lib/blazer.rb +5 -0
- metadata +2 -2
@@ -3,6 +3,9 @@ var runningQueries = []
|
|
3
3
|
var maxQueries = 3
|
4
4
|
|
5
5
|
function runQuery(data, success, error) {
|
6
|
+
if (!data.data_source) {
|
7
|
+
throw new Error("Data source is required to cancel queries")
|
8
|
+
}
|
6
9
|
data.run_id = uuid()
|
7
10
|
var query = {
|
8
11
|
data: data,
|
@@ -50,7 +53,11 @@ function runQueryHelper(query) {
|
|
50
53
|
queryComplete(query)
|
51
54
|
}
|
52
55
|
}).fail( function(jqXHR, textStatus, errorThrown) {
|
53
|
-
|
56
|
+
// check jqXHR.status instead of query.canceled
|
57
|
+
// so it works for page navigation with Firefox and Safari
|
58
|
+
if (jqXHR.status === 0) {
|
59
|
+
cancelServerQuery(query)
|
60
|
+
} else {
|
54
61
|
var message = (typeof errorThrown === "string") ? errorThrown : errorThrown.message
|
55
62
|
if (!message) {
|
56
63
|
message = "An error occurred"
|
@@ -83,6 +90,8 @@ function cancelAllQueries() {
|
|
83
90
|
}
|
84
91
|
}
|
85
92
|
|
93
|
+
// needed for Chrome
|
94
|
+
// queries are canceled before unload with Firefox and Safari
|
86
95
|
$(window).on("unload", cancelAllQueries)
|
87
96
|
|
88
97
|
function cancelQuery(query) {
|
@@ -90,7 +99,9 @@ function cancelQuery(query) {
|
|
90
99
|
if (query.xhr) {
|
91
100
|
query.xhr.abort()
|
92
101
|
}
|
102
|
+
}
|
93
103
|
|
104
|
+
function cancelServerQuery(query) {
|
94
105
|
// tell server
|
95
106
|
var path = Routes.cancel_queries_path()
|
96
107
|
var data = {run_id: query.run_id, data_source: query.data_source}
|
@@ -92,6 +92,7 @@ module Blazer
|
|
92
92
|
@cohort_analysis = @statement.cohort_analysis?
|
93
93
|
|
94
94
|
# fallback for now for users with open tabs
|
95
|
+
# TODO remove fallback in future version
|
95
96
|
@var_params = request.request_parameters["variables"] || request.request_parameters
|
96
97
|
@success = process_vars(@statement, @var_params)
|
97
98
|
@only_chart = params[:only_chart]
|
@@ -133,11 +134,11 @@ module Blazer
|
|
133
134
|
options = {user: blazer_user, query: @query, refresh_cache: params[:check], run_id: @run_id, async: Blazer.async}
|
134
135
|
if Blazer.async && request.format.symbol != :csv
|
135
136
|
Blazer::RunStatementJob.perform_later(@data_source.id, @statement.statement, options.merge(values: @statement.values))
|
136
|
-
wait_start =
|
137
|
+
wait_start = Blazer.monotonic_time
|
137
138
|
loop do
|
138
139
|
sleep(0.1)
|
139
140
|
@result = @data_source.run_results(@run_id)
|
140
|
-
break if @result ||
|
141
|
+
break if @result || Blazer.monotonic_time - wait_start > 3
|
141
142
|
end
|
142
143
|
else
|
143
144
|
@result = Blazer::RunStatement.new.perform(@statement, options)
|
@@ -39,7 +39,9 @@
|
|
39
39
|
</div>
|
40
40
|
</div>
|
41
41
|
<script>
|
42
|
-
|
42
|
+
<% data = {statement: query.statement, query_id: query.id, data_source: query.data_source, variables: variable_params(query), only_chart: true} %>
|
43
|
+
<% data.merge!(cohort_period: params[:cohort_period]) if params[:cohort_period] %>
|
44
|
+
<%= blazer_js_var "data", data %>
|
43
45
|
|
44
46
|
runQuery(data, function (data) {
|
45
47
|
$("#chart-<%= i %>").html(data)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% blazer_title @query.name %>
|
2
2
|
|
3
3
|
<% if @success %>
|
4
|
-
<% run_data = {statement: @query.statement, query_id: @query.id, variables: variable_params(@query)} %>
|
4
|
+
<% run_data = {statement: @query.statement, query_id: @query.id, data_source: @query.data_source, variables: variable_params(@query)} %>
|
5
5
|
<% run_data.merge!(forecast: "t") if params[:forecast] %>
|
6
6
|
<% run_data.merge!(cohort_period: params[:cohort_period]) if params[:cohort_period] %>
|
7
|
-
<% run_data.transform_keys!(&:to_s) if Rails::VERSION::
|
7
|
+
<% run_data.transform_keys!(&:to_s) if Rails::VERSION::MAJOR < 6 %>
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
<div class="topbar">
|
@@ -35,6 +35,9 @@ module Blazer
|
|
35
35
|
error = e.message.sub(/.+ERROR: /, "")
|
36
36
|
error = Blazer::TIMEOUT_MESSAGE if Blazer::TIMEOUT_ERRORS.any? { |e| error.include?(e) }
|
37
37
|
error = Blazer::VARIABLE_MESSAGE if error.include?("syntax error at or near \"$") || error.include?("Incorrect syntax near '@") || error.include?("your MySQL server version for the right syntax to use near '?")
|
38
|
+
if error.include?("could not determine data type of parameter")
|
39
|
+
error += " - try adding casting to variables and make sure none are inside a string literal"
|
40
|
+
end
|
38
41
|
reconnect if error.include?("PG::ConnectionBad")
|
39
42
|
end
|
40
43
|
|
data/lib/blazer/data_source.rb
CHANGED
@@ -145,7 +145,7 @@ module Blazer
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def statement_cache_key(statement)
|
148
|
-
cache_key(["statement", id, Digest::MD5.hexdigest(statement.bind_statement.to_s.gsub("\r\n", "\n") + statement.bind_values.
|
148
|
+
cache_key(["statement", id, Digest::MD5.hexdigest(statement.bind_statement.to_s.gsub("\r\n", "\n") + statement.bind_values.to_json)])
|
149
149
|
end
|
150
150
|
|
151
151
|
def run_cache_key(run_id)
|
@@ -233,14 +233,14 @@ module Blazer
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def run_statement_helper(statement, comment, run_id, options)
|
236
|
-
start_time =
|
236
|
+
start_time = Blazer.monotonic_time
|
237
237
|
columns, rows, error =
|
238
238
|
if adapter_instance.parameter_binding
|
239
239
|
adapter_instance.run_statement(statement.bind_statement, comment, statement.bind_values)
|
240
240
|
else
|
241
241
|
adapter_instance.run_statement(statement.bind_statement, comment)
|
242
242
|
end
|
243
|
-
duration =
|
243
|
+
duration = Blazer.monotonic_time - start_time
|
244
244
|
|
245
245
|
cache_data = nil
|
246
246
|
cache = !error && (cache_mode == "all" || (cache_mode == "slow" && duration >= cache_slow_threshold))
|
data/lib/blazer/run_statement.rb
CHANGED
@@ -17,9 +17,9 @@ module Blazer
|
|
17
17
|
audit.save!
|
18
18
|
end
|
19
19
|
|
20
|
-
start_time =
|
20
|
+
start_time = Blazer.monotonic_time
|
21
21
|
result = data_source.run_statement(statement, options)
|
22
|
-
duration =
|
22
|
+
duration = Blazer.monotonic_time - start_time
|
23
23
|
|
24
24
|
if Blazer.audit
|
25
25
|
audit.duration = duration if audit.respond_to?(:duration=)
|
data/lib/blazer/version.rb
CHANGED
data/lib/blazer.rb
CHANGED
@@ -257,6 +257,11 @@ module Blazer
|
|
257
257
|
viewed_query_ids = Blazer::Audit.where("created_at > ?", 90.days.ago).group(:query_id).count.keys.compact
|
258
258
|
Blazer::Query.active.where.not(id: viewed_query_ids).update_all(status: "archived")
|
259
259
|
end
|
260
|
+
|
261
|
+
# private
|
262
|
+
def self.monotonic_time
|
263
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
264
|
+
end
|
260
265
|
end
|
261
266
|
|
262
267
|
Blazer.register_adapter "athena", Blazer::Adapters::AthenaAdapter
|
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: 2.6.
|
4
|
+
version: 2.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|