blazer 2.6.4 → 2.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,11 +134,11 @@ module Blazer
134
134
  options = {user: blazer_user, query: @query, refresh_cache: params[:check], run_id: @run_id, async: Blazer.async}
135
135
  if Blazer.async && request.format.symbol != :csv
136
136
  Blazer::RunStatementJob.perform_later(@data_source.id, @statement.statement, options.merge(values: @statement.values))
137
- wait_start = Time.now
137
+ wait_start = Blazer.monotonic_time
138
138
  loop do
139
139
  sleep(0.1)
140
140
  @result = @data_source.run_results(@run_id)
141
- break if @result || Time.now - wait_start > 3
141
+ break if @result || Blazer.monotonic_time - wait_start > 3
142
142
  end
143
143
  else
144
144
  @result = Blazer::RunStatement.new.perform(@statement, options)
@@ -4,7 +4,7 @@
4
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::STRING.to_f == 5.0 %>
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
 
@@ -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 = Time.now
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 = Time.now - start_time
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))
@@ -17,9 +17,9 @@ module Blazer
17
17
  audit.save!
18
18
  end
19
19
 
20
- start_time = Time.now
20
+ start_time = Blazer.monotonic_time
21
21
  result = data_source.run_statement(statement, options)
22
- duration = Time.now - start_time
22
+ duration = Blazer.monotonic_time - start_time
23
23
 
24
24
  if Blazer.audit
25
25
  audit.duration = duration if audit.respond_to?(:duration=)
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "2.6.4"
2
+ VERSION = "2.6.5"
3
3
  end
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
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-05-25 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties