blazer 2.6.2 → 2.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94b56694d07907e5b7a1809d710f9a7d2d91cbbdcaff8745944a443bab592a51
4
- data.tar.gz: 3932e924381b13489287911accc9cfe64b492853965b7da8599cc69410b519ff
3
+ metadata.gz: 91a6508a46423aa3acbe9151fcc3a7519b27daacaff1ec46a2c5e5cb7afed8f1
4
+ data.tar.gz: 92f9465aed0bca2ba03b320e6b550271c1fff5c7a06a56905bf51a964e012046
5
5
  SHA512:
6
- metadata.gz: 0d845eb1ca60826cbf6ec2af049e5bcfdf6a9dc273f2c3d0a4899be16d51fcdddf6b6b00df96b3665bf18558b4669383301ab820718d3a8830b830d34564cdfa
7
- data.tar.gz: 8fe5f0873319879f6aad49c8e46aeac989dce40d5932bdcd55e3667b132214774da8d06acc323d16b5a47ef40f95b3f67c7899e5e3e008303b18b89b15502f3c
6
+ metadata.gz: 5e4b04de87e7b0f32d3cb6f88c02634f4b400bcb9281f4fc9b39db80579abea02feab25f4e7ede93793af5a05a46160d70f8789b37e4d7914ef61427d0e2edeb
7
+ data.tar.gz: 49a48fdee3660a4178f3df8619f7bee4677da27431af2500d4e312db698090989868778ae8b544cf20f636aa71e63771148ab3a858229a2c1d3ce622258119f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.6.3 (2022-05-11)
2
+
3
+ - Fixed error with canceling queries
4
+
1
5
  ## 2.6.2 (2022-05-06)
2
6
 
3
7
  - Fixed error with Postgres when prepared statements are disabled with Rails < 6.1
data/README.md CHANGED
@@ -150,8 +150,8 @@ Create a user with read-only permissions:
150
150
 
151
151
  ```sql
152
152
  BEGIN;
153
- CREATE ROLE blazer LOGIN PASSWORD 'secret123';
154
- GRANT CONNECT ON DATABASE database_name TO blazer;
153
+ CREATE ROLE blazer LOGIN PASSWORD 'secret';
154
+ GRANT CONNECT ON DATABASE dbname TO blazer;
155
155
  GRANT USAGE ON SCHEMA public TO blazer;
156
156
  GRANT SELECT ON ALL TABLES IN SCHEMA public TO blazer;
157
157
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
@@ -163,7 +163,8 @@ COMMIT;
163
163
  Create a user with read-only permissions:
164
164
 
165
165
  ```sql
166
- GRANT SELECT, SHOW VIEW ON database_name.* TO blazer@’127.0.0.1 IDENTIFIED BY ‘secret123‘;
166
+ CREATE USER 'blazer'@'127.0.0.1' IDENTIFIED BY 'secret';
167
+ GRANT SELECT, SHOW VIEW ON dbname.* TO 'blazer'@'127.0.0.1';
167
168
  FLUSH PRIVILEGES;
168
169
  ```
169
170
 
@@ -171,8 +172,8 @@ FLUSH PRIVILEGES;
171
172
 
172
173
  Create a user with read-only permissions:
173
174
 
174
- ```
175
- db.createUser({user: "blazer", pwd: "password", roles: ["read"]})
175
+ ```javascript
176
+ db.createUser({user: "blazer", pwd: "secret", roles: ["read"]})
176
177
  ```
177
178
 
178
179
  Also, make sure authorization is enabled when you start the server.
@@ -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
- if (!query.canceled) {
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}
@@ -39,7 +39,9 @@
39
39
  </div>
40
40
  </div>
41
41
  <script>
42
- <%= blazer_js_var "data", {statement: query.statement, query_id: query.id, variables: variable_params(query), only_chart: true, cohort_period: params[:cohort_period]} %>
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,7 +1,7 @@
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
7
  <% run_data.transform_keys!(&:to_s) if Rails::VERSION::STRING.to_f == 5.0 %>
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "2.6.2"
2
+ VERSION = "2.6.3"
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: 2.6.2
4
+ version: 2.6.3
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-06 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties