blazer 2.2.5 → 2.2.6
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +34 -8
- data/app/views/blazer/queries/show.html.erb +3 -1
- data/lib/blazer.rb +2 -0
- data/lib/blazer/adapters/influxdb_adapter.rb +45 -0
- data/lib/blazer/result.rb +2 -21
- data/lib/blazer/version.rb +1 -1
- data/lib/generators/blazer/templates/install.rb.tt +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfb774d21d8d5756c2fc273c2148542e26550452ea886adf92023c411b45200a
|
4
|
+
data.tar.gz: 8200979166341f38e0647fbb566f1fd8ead6895ea254a12ead4901e344d80f38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6705d3dd2c27db9aeb36b9afd2e9a335d876f36865c5bbaade10f13cca80436ec3c31787231c16b591fd78481cdbb7f11df82de00417fd71d5005b1db038b11
|
7
|
+
data.tar.gz: 50c2230e80ad2a0e487197c8593a4c774a0f58304ed88b704860ce4550029202f677042a685b7457a57c67b6e660a82f4692ba529a5eabb41c17d2d1182c3fce
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -434,12 +434,10 @@ A forecast link will appear for queries that return 2 columns with types timesta
|
|
434
434
|
|
435
435
|
### Prophet
|
436
436
|
|
437
|
-
**Note:** Prophet only supports daily forecasts right now.
|
438
|
-
|
439
437
|
Add [prophet](https://github.com/ankane/prophet) to your Gemfile:
|
440
438
|
|
441
439
|
```ruby
|
442
|
-
gem 'prophet-rb'
|
440
|
+
gem 'prophet-rb', '>= 0.2.1'
|
443
441
|
```
|
444
442
|
|
445
443
|
And add to `config/blazer.yml`:
|
@@ -493,6 +491,7 @@ data_sources:
|
|
493
491
|
- [Elasticsearch](#elasticsearch)
|
494
492
|
- [Google BigQuery](#google-bigquery)
|
495
493
|
- [IBM DB2 and Informix](#ibm-db2-and-informix)
|
494
|
+
- [InfluxDB](#influxdb)
|
496
495
|
- [MongoDB](#mongodb-1)
|
497
496
|
- [MySQL](#mysql-1)
|
498
497
|
- [Neo4j](#neo4j)
|
@@ -529,7 +528,7 @@ data_sources:
|
|
529
528
|
|
530
529
|
### Amazon Redshift
|
531
530
|
|
532
|
-
Add [
|
531
|
+
Add [activerecord6-redshift-adapter](https://github.com/kwent/activerecord6-redshift-adapter) or [activerecord5-redshift-adapter](https://github.com/ConsultingMD/activerecord5-redshift-adapter) to your Gemfile and set:
|
533
532
|
|
534
533
|
```yml
|
535
534
|
data_sources:
|
@@ -594,7 +593,28 @@ data_sources:
|
|
594
593
|
|
595
594
|
### IBM DB2 and Informix
|
596
595
|
|
597
|
-
|
596
|
+
Add [ibm_db](https://github.com/ibmdb/ruby-ibmdb) to your Gemfile and set:
|
597
|
+
|
598
|
+
```yml
|
599
|
+
data_sources:
|
600
|
+
my_source:
|
601
|
+
url: ibm-db://user:password@hostname:50000/database
|
602
|
+
```
|
603
|
+
|
604
|
+
### InfluxDB
|
605
|
+
|
606
|
+
*Experimental*
|
607
|
+
|
608
|
+
Add [influxdb](https://github.com/influxdata/influxdb-ruby) to your Gemfile and set:
|
609
|
+
|
610
|
+
```yml
|
611
|
+
data_sources:
|
612
|
+
my_source:
|
613
|
+
adapter: influxdb
|
614
|
+
url: http://user:password@hostname:8086/database
|
615
|
+
```
|
616
|
+
|
617
|
+
Supports [InfluxQL](https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/)
|
598
618
|
|
599
619
|
### MongoDB
|
600
620
|
|
@@ -631,11 +651,17 @@ data_sources:
|
|
631
651
|
|
632
652
|
### Oracle
|
633
653
|
|
634
|
-
|
654
|
+
Add [activerecord-oracle_enhanced-adapter](https://github.com/rsim/oracle-enhanced) and [ruby-oci8](https://github.com/kubo/ruby-oci8) to your Gemfile and set:
|
655
|
+
|
656
|
+
```yml
|
657
|
+
data_sources:
|
658
|
+
my_source:
|
659
|
+
url: oracle-enhanced://user:password@hostname:1521/database
|
660
|
+
```
|
635
661
|
|
636
662
|
### PostgreSQL
|
637
663
|
|
638
|
-
Add [pg](https://
|
664
|
+
Add [pg](https://github.com/ged/ruby-pg) to your Gemfile (if it’s not there) and set:
|
639
665
|
|
640
666
|
```yml
|
641
667
|
data_sources:
|
@@ -712,7 +738,7 @@ For Heroku, use the [Apt buildpack](https://github.com/heroku/heroku-buildpack-a
|
|
712
738
|
|
713
739
|
```text
|
714
740
|
unixodbc-dev
|
715
|
-
https://sfc-repo.snowflakecomputing.com/odbc/linux/2.
|
741
|
+
https://sfc-repo.snowflakecomputing.com/odbc/linux/2.21.5/snowflake-odbc-2.21.5.x86_64.deb
|
716
742
|
```
|
717
743
|
|
718
744
|
> This installs the driver at `/app/.apt/usr/lib/snowflake/odbc/lib/libSnowflake.so`
|
@@ -56,7 +56,9 @@
|
|
56
56
|
$("#results").addClass("query-error").html(message)
|
57
57
|
}
|
58
58
|
|
59
|
-
|
59
|
+
<% data = variable_params(@query).merge(statement: @statement, query_id: @query.id, data_source: @query.data_source) %>
|
60
|
+
<% data.merge!(forecast: "t") if params[:forecast] %>
|
61
|
+
<%= blazer_js_var "data", data %>
|
60
62
|
|
61
63
|
runQuery(data, showRun, showError)
|
62
64
|
</script>
|
data/lib/blazer.rb
CHANGED
@@ -18,6 +18,7 @@ require "blazer/adapters/cassandra_adapter"
|
|
18
18
|
require "blazer/adapters/drill_adapter"
|
19
19
|
require "blazer/adapters/druid_adapter"
|
20
20
|
require "blazer/adapters/elasticsearch_adapter"
|
21
|
+
require "blazer/adapters/influxdb_adapter"
|
21
22
|
require "blazer/adapters/mongodb_adapter"
|
22
23
|
require "blazer/adapters/neo4j_adapter"
|
23
24
|
require "blazer/adapters/presto_adapter"
|
@@ -220,6 +221,7 @@ Blazer.register_adapter "cassandra", Blazer::Adapters::CassandraAdapter
|
|
220
221
|
Blazer.register_adapter "drill", Blazer::Adapters::DrillAdapter
|
221
222
|
Blazer.register_adapter "druid", Blazer::Adapters::DruidAdapter
|
222
223
|
Blazer.register_adapter "elasticsearch", Blazer::Adapters::ElasticsearchAdapter
|
224
|
+
Blazer.register_adapter "influxdb", Blazer::Adapters::InfluxdbAdapter
|
223
225
|
Blazer.register_adapter "neo4j", Blazer::Adapters::Neo4jAdapter
|
224
226
|
Blazer.register_adapter "presto", Blazer::Adapters::PrestoAdapter
|
225
227
|
Blazer.register_adapter "mongodb", Blazer::Adapters::MongodbAdapter
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Blazer
|
2
|
+
module Adapters
|
3
|
+
class InfluxdbAdapter < BaseAdapter
|
4
|
+
def run_statement(statement, comment)
|
5
|
+
columns = []
|
6
|
+
rows = []
|
7
|
+
error = nil
|
8
|
+
|
9
|
+
begin
|
10
|
+
result = client.query(statement, denormalize: false).first
|
11
|
+
columns = result["columns"]
|
12
|
+
rows = result["values"]
|
13
|
+
|
14
|
+
# parse time columns
|
15
|
+
# current approach isn't ideal, but result doesn't include types
|
16
|
+
# another approach would be to check the format
|
17
|
+
time_index = columns.index("time")
|
18
|
+
if time_index
|
19
|
+
rows.each do |row|
|
20
|
+
row[time_index] = Time.parse(row[time_index]) if row[time_index]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
rescue => e
|
24
|
+
error = e.message
|
25
|
+
end
|
26
|
+
|
27
|
+
[columns, rows, error]
|
28
|
+
end
|
29
|
+
|
30
|
+
def tables
|
31
|
+
client.list_series
|
32
|
+
end
|
33
|
+
|
34
|
+
def preview_statement
|
35
|
+
"SELECT * FROM {table} LIMIT 10"
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def client
|
41
|
+
@client ||= InfluxDB::Client.new(url: settings["url"])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/blazer/result.rb
CHANGED
@@ -94,29 +94,10 @@ module Blazer
|
|
94
94
|
case Blazer.forecasting
|
95
95
|
when "prophet"
|
96
96
|
require "prophet"
|
97
|
-
|
98
|
-
df =
|
99
|
-
Daru::DataFrame.new(
|
100
|
-
"ds" => @rows.map { |r| r[0] },
|
101
|
-
"y" => @rows.map { |r| r[1] }
|
102
|
-
)
|
103
|
-
|
104
|
-
# TODO determine frequency
|
105
|
-
freq = "D"
|
106
|
-
|
107
|
-
m = Prophet.new
|
108
|
-
m.fit(df)
|
109
|
-
future = m.make_future_dataframe(periods: count, freq: freq, include_history: false)
|
110
|
-
fcst = m.predict(future)
|
111
|
-
ds = fcst["ds"]
|
112
|
-
if @rows[0][0].is_a?(Date)
|
113
|
-
ds = ds.map { |v| v.to_date }
|
114
|
-
end
|
115
|
-
forecast = ds.zip(fcst["yhat"]).to_h
|
97
|
+
forecast = Prophet.forecast(@rows.to_h, count: count)
|
116
98
|
else
|
117
99
|
require "trend"
|
118
|
-
|
119
|
-
forecast = Trend.forecast(Hash[@rows], count: count)
|
100
|
+
forecast = Trend.forecast(@rows.to_h, count: count)
|
120
101
|
end
|
121
102
|
|
122
103
|
# round integers
|
data/lib/blazer/version.rb
CHANGED
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.2.
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/blazer/adapters/drill_adapter.rb
|
186
186
|
- lib/blazer/adapters/druid_adapter.rb
|
187
187
|
- lib/blazer/adapters/elasticsearch_adapter.rb
|
188
|
+
- lib/blazer/adapters/influxdb_adapter.rb
|
188
189
|
- lib/blazer/adapters/mongodb_adapter.rb
|
189
190
|
- lib/blazer/adapters/neo4j_adapter.rb
|
190
191
|
- lib/blazer/adapters/presto_adapter.rb
|