blazer 3.0.0 → 3.3.0
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 +4 -4
- data/CHANGELOG.md +57 -0
- data/LICENSE.txt +1 -1
- data/README.md +69 -102
- data/app/controllers/blazer/base_controller.rb +5 -3
- data/app/controllers/blazer/queries_controller.rb +12 -2
- data/app/views/blazer/_variables.html.erb +8 -8
- data/app/views/blazer/checks/_form.html.erb +8 -8
- data/app/views/blazer/checks/index.html.erb +2 -2
- data/app/views/blazer/dashboards/_form.html.erb +2 -2
- data/app/views/blazer/dashboards/show.html.erb +2 -2
- data/app/views/blazer/queries/_form.html.erb +2 -2
- data/app/views/blazer/queries/home.html.erb +2 -2
- data/app/views/blazer/queries/run.html.erb +7 -7
- data/app/views/blazer/queries/schema.html.erb +3 -3
- data/app/views/blazer/queries/show.html.erb +4 -4
- data/app/views/blazer/uploads/index.html.erb +2 -2
- data/app/views/layouts/blazer/application.html.erb +5 -5
- data/lib/blazer/adapters/athena_adapter.rb +1 -1
- data/lib/blazer/adapters/hive_adapter.rb +1 -1
- data/lib/blazer/adapters/neo4j_adapter.rb +41 -13
- data/lib/blazer/adapters/presto_adapter.rb +4 -3
- data/lib/blazer/adapters/sql_adapter.rb +54 -17
- data/lib/blazer/adapters.rb +1 -0
- data/lib/blazer/data_source.rb +2 -2
- data/lib/blazer/engine.rb +18 -16
- data/lib/blazer/result.rb +2 -2
- data/lib/blazer/run_statement.rb +2 -1
- data/lib/blazer/statement.rb +6 -3
- data/lib/blazer/version.rb +1 -1
- metadata +22 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c0195ef0a71f12d25336eeb7e50ddcf7a307480a34c778c884d805cb046068e
|
4
|
+
data.tar.gz: '068f14c8b5c5df75a8638fd1f6354d9957f56fc3bf855944dadb23ce69aa336a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fe14dbedbe3705c61339074437c2117d102d03a15050a3caaa9df4b2077937911891b01a1d4afd92ca432330191133a1f8e098d2695d050c00799a918badf82
|
7
|
+
data.tar.gz: 074d5b2d452d90741a950257fb69b96b01f3e3d0b5ae5570a096d6a23e17d529322018b3d4ebad2ca5793fa77386d41c1472c22fa9a8f272c5026e5ccca4e618
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
## 3.3.0 (2025-04-12)
|
2
|
+
|
3
|
+
- Fixed error with forecasting with Rails 7.2+
|
4
|
+
- Dropped support for Ruby < 3.2 and Rails < 7.1
|
5
|
+
|
6
|
+
## 3.2.1 (2025-03-21)
|
7
|
+
|
8
|
+
- Added thousands separator to charts
|
9
|
+
- Improved i18n for charts
|
10
|
+
- Fixed leading zeros in variables
|
11
|
+
|
12
|
+
## 3.2.0 (2025-02-23)
|
13
|
+
|
14
|
+
- Added support for Trino
|
15
|
+
- Added support for `neo4j-ruby-driver` gem
|
16
|
+
- Fixed types for SQLite
|
17
|
+
- Fixed table preview and schema page for SQLite
|
18
|
+
|
19
|
+
## 3.1.0 (2024-10-14)
|
20
|
+
|
21
|
+
- Fixed error when Propshaft is installed but not used
|
22
|
+
- Dropped support for Ruby < 3.1 and Rails < 7
|
23
|
+
|
24
|
+
## 3.0.4 (2024-09-04)
|
25
|
+
|
26
|
+
- Improved CSP support
|
27
|
+
- Fixed error with Trilogy and Rails 7.2
|
28
|
+
|
29
|
+
## 3.0.3 (2024-01-10)
|
30
|
+
|
31
|
+
- Fixed error with Trilogy, non-ASCII column names, and charts
|
32
|
+
|
33
|
+
## 3.0.2 (2023-11-28)
|
34
|
+
|
35
|
+
- Fixed error with SQLite and prepared statements
|
36
|
+
|
37
|
+
## 3.0.1 (2023-10-08)
|
38
|
+
|
39
|
+
- Fixed error with Rails 7.1 when no user model
|
40
|
+
|
1
41
|
## 3.0.0 (2023-09-20)
|
2
42
|
|
3
43
|
- Switched from Mapbox.js to Mapbox GL JS v1 for maps (this affects Mapbox billing)
|
@@ -424,3 +464,20 @@ There was no 1.8.1 release.
|
|
424
464
|
- Added support for Rails 4.2
|
425
465
|
- Fixed error with `mysql2` adapter
|
426
466
|
- Added `user_class` option
|
467
|
+
|
468
|
+
## 0.0.4 (2014-11-19)
|
469
|
+
|
470
|
+
- Added timeout
|
471
|
+
|
472
|
+
## 0.0.3 (2014-10-08)
|
473
|
+
|
474
|
+
- Made editor bigger
|
475
|
+
|
476
|
+
## 0.0.2 (2014-10-01)
|
477
|
+
|
478
|
+
- Added query to audits
|
479
|
+
- Added `user_name` option
|
480
|
+
|
481
|
+
## 0.0.1 (2014-09-30)
|
482
|
+
|
483
|
+
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,13 +4,13 @@ Explore your data with SQL. Easily create charts and dashboards, and share them
|
|
4
4
|
|
5
5
|
[Try it out](https://blazer.dokkuapp.com)
|
6
6
|
|
7
|
-
[](https://blazer.dokkuapp.com)
|
8
8
|
|
9
9
|
Blazer is also available as a [Docker image](https://github.com/ankane/blazer-docker).
|
10
10
|
|
11
11
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
12
12
|
|
13
|
-
[](https://github.com/ankane/blazer/actions)
|
14
14
|
|
15
15
|
## Features
|
16
16
|
|
@@ -71,7 +71,7 @@ Be sure to set a host in `config/environments/production.rb` for emails to work.
|
|
71
71
|
config.action_mailer.default_url_options = {host: "blazer.dokkuapp.com"}
|
72
72
|
```
|
73
73
|
|
74
|
-
Schedule checks to run (with cron, [Heroku Scheduler](https://elements.heroku.com/addons/scheduler), etc). The default options are every 5 minutes, 1 hour, or 1 day, which you can customize. For each of these options, set up a task to run.
|
74
|
+
Schedule checks to run (with cron, Solid Queue, [Heroku Scheduler](https://elements.heroku.com/addons/scheduler), etc). The default options are every 5 minutes, 1 hour, or 1 day, which you can customize. For each of these options, set up a task to run.
|
75
75
|
|
76
76
|
```sh
|
77
77
|
rake blazer:run_checks SCHEDULE="5 minutes"
|
@@ -94,6 +94,24 @@ Here’s what it looks like with cron.
|
|
94
94
|
0 8 * * * rake blazer:send_failing_checks
|
95
95
|
```
|
96
96
|
|
97
|
+
For Solid Queue, update `config/recurring.yml`.
|
98
|
+
|
99
|
+
```yml
|
100
|
+
production:
|
101
|
+
blazer_run_checks_5_minutes:
|
102
|
+
command: "Blazer.run_checks(schedule: '5 minutes')"
|
103
|
+
schedule: every 5 minutes
|
104
|
+
blazer_run_checks_1_hour:
|
105
|
+
command: "Blazer.run_checks(schedule: '1 hour')"
|
106
|
+
schedule: every hour
|
107
|
+
blazer_run_checks_1_day:
|
108
|
+
command: "Blazer.run_checks(schedule: '1 day')"
|
109
|
+
schedule: every day at 7:30am
|
110
|
+
blazer_send_failing_checks:
|
111
|
+
command: "Blazer.send_failing_checks"
|
112
|
+
schedule: every day at 8am
|
113
|
+
```
|
114
|
+
|
97
115
|
For Slack notifications, create an [incoming webhook](https://slack.com/apps/A0F7XDUAZ-incoming-webhooks) and set:
|
98
116
|
|
99
117
|
```sh
|
@@ -125,7 +143,7 @@ end
|
|
125
143
|
|
126
144
|
### Other
|
127
145
|
|
128
|
-
Specify a `before_action` method to run in `blazer.yml`.
|
146
|
+
Specify a `before_action` method to run in `config/blazer.yml`.
|
129
147
|
|
130
148
|
```yml
|
131
149
|
before_action_method: require_admin
|
@@ -136,7 +154,7 @@ You can define this method in your `ApplicationController`.
|
|
136
154
|
```ruby
|
137
155
|
def require_admin
|
138
156
|
# depending on your auth, something like...
|
139
|
-
redirect_to root_path unless current_user && current_user.admin?
|
157
|
+
redirect_to main_app.root_path unless current_user && current_user.admin?
|
140
158
|
end
|
141
159
|
```
|
142
160
|
|
@@ -158,7 +176,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
|
|
158
176
|
COMMIT;
|
159
177
|
```
|
160
178
|
|
161
|
-
### MySQL
|
179
|
+
### MySQL and MariaDB
|
162
180
|
|
163
181
|
Create a user with read-only permissions:
|
164
182
|
|
@@ -213,7 +231,7 @@ SELECT * FROM users WHERE occupation_id = {occupation_id}
|
|
213
231
|
|
214
232
|
Instead of remembering each occupation’s id, users can select occupations by name.
|
215
233
|
|
216
|
-
Add a smart variable with:
|
234
|
+
Add a smart variable in `config/blazer.yml` with:
|
217
235
|
|
218
236
|
```yml
|
219
237
|
smart_variables:
|
@@ -431,24 +449,22 @@ anomaly_checks: prophet
|
|
431
449
|
|
432
450
|
### Trend
|
433
451
|
|
434
|
-
[Trend](https://trendapi.org/) uses an external service by default, but you can run it on your own infrastructure as well.
|
435
|
-
|
436
452
|
Add [trend](https://github.com/ankane/trend) to your Gemfile:
|
437
453
|
|
438
454
|
```ruby
|
439
455
|
gem "trend"
|
440
456
|
```
|
441
457
|
|
442
|
-
|
458
|
+
Set the URL to the [API](https://github.com/ankane/trend-api) in an initializer:
|
443
459
|
|
444
|
-
```
|
445
|
-
|
460
|
+
```ruby
|
461
|
+
Trend.url = "http://localhost:8000"
|
446
462
|
```
|
447
463
|
|
448
|
-
|
464
|
+
And add to `config/blazer.yml`:
|
449
465
|
|
450
|
-
```
|
451
|
-
|
466
|
+
```yml
|
467
|
+
anomaly_checks: trend
|
452
468
|
```
|
453
469
|
|
454
470
|
### AnomalyDetection.rb
|
@@ -487,24 +503,22 @@ forecasting: prophet
|
|
487
503
|
|
488
504
|
### Trend
|
489
505
|
|
490
|
-
[Trend](https://trendapi.org/) uses an external service by default, but you can run it on your own infrastructure as well.
|
491
|
-
|
492
506
|
Add [trend](https://github.com/ankane/trend) to your Gemfile:
|
493
507
|
|
494
508
|
```ruby
|
495
509
|
gem "trend"
|
496
510
|
```
|
497
511
|
|
498
|
-
|
512
|
+
Set the URL to the [API](https://github.com/ankane/trend-api) in an initializer:
|
499
513
|
|
500
|
-
```
|
501
|
-
|
514
|
+
```ruby
|
515
|
+
Trend.url = "http://localhost:8000"
|
502
516
|
```
|
503
517
|
|
504
|
-
|
518
|
+
And add to `config/blazer.yml`:
|
505
519
|
|
506
|
-
```
|
507
|
-
|
520
|
+
```yml
|
521
|
+
forecasting: trend
|
508
522
|
```
|
509
523
|
|
510
524
|
## Uploads
|
@@ -566,15 +580,15 @@ data_sources:
|
|
566
580
|
- [Google BigQuery](#google-bigquery)
|
567
581
|
- [IBM DB2 and Informix](#ibm-db2-and-informix)
|
568
582
|
- [InfluxDB](#influxdb)
|
569
|
-
- [MySQL](#mysql-1)
|
583
|
+
- [MySQL and MariaDB](#mysql-and-mariadb-1)
|
570
584
|
- [Neo4j](#neo4j)
|
571
585
|
- [OpenSearch](#opensearch)
|
572
586
|
- [Oracle](#oracle)
|
573
587
|
- [PostgreSQL](#postgresql-1)
|
574
|
-
- [Presto](#presto)
|
588
|
+
- [Presto and Trino](#presto-and-trino)
|
575
589
|
- [Salesforce](#salesforce)
|
576
|
-
- [Socrata Open Data API (SODA)](#socrata-open-data-api-soda)
|
577
590
|
- [Snowflake](#snowflake)
|
591
|
+
- [Socrata Open Data API (SODA)](#socrata-open-data-api-soda)
|
578
592
|
- [SQLite](#sqlite)
|
579
593
|
- [SQL Server](#sql-server)
|
580
594
|
|
@@ -639,11 +653,11 @@ Here’s an example IAM policy:
|
|
639
653
|
}
|
640
654
|
```
|
641
655
|
|
642
|
-
You also need to configure [S3 permissions](https://aws
|
656
|
+
You also need to configure [S3 permissions](https://repost.aws/knowledge-center/access-denied-athena).
|
643
657
|
|
644
658
|
### Amazon Redshift
|
645
659
|
|
646
|
-
Add [
|
660
|
+
Add [activerecord7-redshift-adapter-pennylane](https://github.com/pennylane-hq/activerecord-adapter-redshift) to your Gemfile and set:
|
647
661
|
|
648
662
|
```yml
|
649
663
|
data_sources:
|
@@ -706,7 +720,7 @@ Use a read-only user. Requires the [Thrift server](https://spark.apache.org/docs
|
|
706
720
|
|
707
721
|
### Cassandra
|
708
722
|
|
709
|
-
Add [cassandra-driver](https://github.com/datastax/ruby-driver)
|
723
|
+
Add [cassandra-driver](https://github.com/datastax/ruby-driver) and [sorted_set](https://github.com/knu/sorted_set) to your Gemfile and set:
|
710
724
|
|
711
725
|
```yml
|
712
726
|
data_sources:
|
@@ -718,7 +732,7 @@ Use a [read-only role](https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/us
|
|
718
732
|
|
719
733
|
### Druid
|
720
734
|
|
721
|
-
Enable [SQL support](
|
735
|
+
Enable [SQL support](https://druid.apache.org/docs/latest/querying/sql) on the broker and set:
|
722
736
|
|
723
737
|
```yml
|
724
738
|
data_sources:
|
@@ -744,7 +758,7 @@ Use a [read-only role](https://www.elastic.co/guide/en/elasticsearch/reference/c
|
|
744
758
|
|
745
759
|
### Google BigQuery
|
746
760
|
|
747
|
-
Add [google-cloud-bigquery](https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/
|
761
|
+
Add [google-cloud-bigquery](https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/main/google-cloud-bigquery) to your Gemfile and set:
|
748
762
|
|
749
763
|
```yml
|
750
764
|
data_sources:
|
@@ -779,7 +793,7 @@ data_sources:
|
|
779
793
|
|
780
794
|
Use a [read-only user](https://docs.influxdata.com/influxdb/v1.8/administration/authentication_and_authorization/). Supports [InfluxQL](https://docs.influxdata.com/influxdb/v1.8/query_language/explore-data/).
|
781
795
|
|
782
|
-
### MySQL
|
796
|
+
### MySQL and MariaDB
|
783
797
|
|
784
798
|
Add [mysql2](https://github.com/brianmario/mysql2) to your Gemfile (if it’s not there) and set:
|
785
799
|
|
@@ -789,17 +803,17 @@ data_sources:
|
|
789
803
|
url: mysql2://user:password@hostname:3306/database
|
790
804
|
```
|
791
805
|
|
792
|
-
Use a [read-only user](#mysql).
|
806
|
+
Use a [read-only user](#mysql-and-mariadb).
|
793
807
|
|
794
808
|
### Neo4j
|
795
809
|
|
796
|
-
Add [neo4j-
|
810
|
+
Add [neo4j-ruby-driver](https://github.com/neo4jrb/neo4j-ruby-driver) to your Gemfile and set:
|
797
811
|
|
798
812
|
```yml
|
799
813
|
data_sources:
|
800
814
|
my_source:
|
801
815
|
adapter: neo4j
|
802
|
-
url:
|
816
|
+
url: bolt://user:password@hostname:7687/database
|
803
817
|
```
|
804
818
|
|
805
819
|
Use a [read-only user](https://neo4j.com/docs/cypher-manual/current/access-control/manage-privileges/).
|
@@ -841,17 +855,19 @@ data_sources:
|
|
841
855
|
|
842
856
|
Use a [read-only user](#postgresql).
|
843
857
|
|
844
|
-
### Presto
|
858
|
+
### Presto and Trino
|
845
859
|
|
846
|
-
Add [presto-client](https://github.com/treasure-data/
|
860
|
+
Add [presto-client](https://github.com/treasure-data/trino-client-ruby/tree/v0.6.5) or [trino-client](https://github.com/treasure-data/trino-client-ruby) to your Gemfile and set:
|
847
861
|
|
848
862
|
```yml
|
849
863
|
data_sources:
|
850
864
|
my_source:
|
851
865
|
url: presto://user@hostname:8080/catalog
|
866
|
+
# or
|
867
|
+
url: trino://user@hostname:8080/catalog
|
852
868
|
```
|
853
869
|
|
854
|
-
Use a
|
870
|
+
Use a read-only user for [Presto](https://prestodb.io/docs/current/security/built-in-system-access-control.html) or [Trino](https://trino.io/docs/current/security/built-in-system-access-control.html).
|
855
871
|
|
856
872
|
### Salesforce
|
857
873
|
|
@@ -876,20 +892,6 @@ SALESFORCE_API_VERSION="41.0"
|
|
876
892
|
|
877
893
|
Use a read-only user. Supports [SOQL](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm).
|
878
894
|
|
879
|
-
### Socrata Open Data API (SODA)
|
880
|
-
|
881
|
-
Set:
|
882
|
-
|
883
|
-
```yml
|
884
|
-
data_sources:
|
885
|
-
my_source:
|
886
|
-
adapter: soda
|
887
|
-
url: https://soda.demo.socrata.com/resource/4tka-6guv.json
|
888
|
-
app_token: ...
|
889
|
-
```
|
890
|
-
|
891
|
-
Supports [SoQL](https://dev.socrata.com/docs/functions/).
|
892
|
-
|
893
895
|
### Snowflake
|
894
896
|
|
895
897
|
First, install ODBC. For Homebrew, use:
|
@@ -913,7 +915,7 @@ https://sfc-repo.snowflakecomputing.com/odbc/linux/2.21.5/snowflake-odbc-2.21.5.
|
|
913
915
|
|
914
916
|
> This installs the driver at `/app/.apt/usr/lib/snowflake/odbc/lib/libSnowflake.so`
|
915
917
|
|
916
|
-
Then, download the [Snowflake ODBC driver](https://docs.snowflake.
|
918
|
+
Then, download the [Snowflake ODBC driver](https://docs.snowflake.com/developer-guide/odbc/odbc-download). Add [odbc_adapter](https://github.com/localytics/odbc_adapter) to your Gemfile and set:
|
917
919
|
|
918
920
|
```yml
|
919
921
|
data_sources:
|
@@ -924,6 +926,20 @@ data_sources:
|
|
924
926
|
|
925
927
|
Use a [read-only role](https://docs.snowflake.com/en/user-guide/security-access-control-configure.html).
|
926
928
|
|
929
|
+
### Socrata Open Data API (SODA)
|
930
|
+
|
931
|
+
Set:
|
932
|
+
|
933
|
+
```yml
|
934
|
+
data_sources:
|
935
|
+
my_source:
|
936
|
+
adapter: soda
|
937
|
+
url: https://soda.demo.socrata.com/resource/4tka-6guv.json
|
938
|
+
app_token: ...
|
939
|
+
```
|
940
|
+
|
941
|
+
Supports [SoQL](https://dev.socrata.com/docs/functions/).
|
942
|
+
|
927
943
|
### SQLite
|
928
944
|
|
929
945
|
Add [sqlite3](https://github.com/sparklemotion/sqlite3-ruby) to your Gemfile and set:
|
@@ -986,10 +1002,6 @@ Have team members who want to learn SQL? Here are a few great, free resources.
|
|
986
1002
|
|
987
1003
|
For an easy way to group by day, week, month, and more with correct time zones, check out [Groupdate.sql](https://github.com/ankane/groupdate.sql).
|
988
1004
|
|
989
|
-
## Standalone Version
|
990
|
-
|
991
|
-
Looking for a standalone version? Check out [Ghost Blazer](https://github.com/buren/ghost_blazer).
|
992
|
-
|
993
1005
|
## Performance
|
994
1006
|
|
995
1007
|
By default, queries take up a request while they are running. To run queries asynchronously, add to your config:
|
@@ -1026,51 +1038,6 @@ override_csp: true
|
|
1026
1038
|
|
1027
1039
|
Maps now use Mapbox GL JS v1 instead of Mapbox.js, which affects Mapbox billing.
|
1028
1040
|
|
1029
|
-
### 2.6
|
1030
|
-
|
1031
|
-
Custom adapters now need to specify how to quote variables in queries (there is no longer a default)
|
1032
|
-
|
1033
|
-
```ruby
|
1034
|
-
class FooAdapter < Blazer::Adapters::BaseAdapter
|
1035
|
-
def quoting
|
1036
|
-
:backslash_escape # single quote strings and convert ' to \' and \ to \\
|
1037
|
-
# or
|
1038
|
-
:single_quote_escape # single quote strings and convert ' to ''
|
1039
|
-
# or
|
1040
|
-
->(value) { ... } # custom method
|
1041
|
-
end
|
1042
|
-
end
|
1043
|
-
```
|
1044
|
-
|
1045
|
-
### 2.3
|
1046
|
-
|
1047
|
-
To archive queries, create a migration
|
1048
|
-
|
1049
|
-
```sh
|
1050
|
-
rails g migration add_status_to_blazer_queries
|
1051
|
-
```
|
1052
|
-
|
1053
|
-
with:
|
1054
|
-
|
1055
|
-
```ruby
|
1056
|
-
add_column :blazer_queries, :status, :string
|
1057
|
-
Blazer::Query.update_all(status: "active")
|
1058
|
-
```
|
1059
|
-
|
1060
|
-
### 2.0
|
1061
|
-
|
1062
|
-
To use Slack notifications, create a migration
|
1063
|
-
|
1064
|
-
```sh
|
1065
|
-
rails g migration add_slack_channels_to_blazer_checks
|
1066
|
-
```
|
1067
|
-
|
1068
|
-
with:
|
1069
|
-
|
1070
|
-
```ruby
|
1071
|
-
add_column :blazer_checks, :slack_channels, :text
|
1072
|
-
```
|
1073
|
-
|
1074
1041
|
## History
|
1075
1042
|
|
1076
1043
|
View the [changelog](https://github.com/ankane/blazer/blob/master/CHANGELOG.md)
|
@@ -30,6 +30,8 @@ module Blazer
|
|
30
30
|
|
31
31
|
layout "blazer/application"
|
32
32
|
|
33
|
+
default_form_builder ::ActionView::Helpers::FormBuilder
|
34
|
+
|
33
35
|
private
|
34
36
|
|
35
37
|
def process_vars(statement, var_params = nil)
|
@@ -69,9 +71,9 @@ module Blazer
|
|
69
71
|
if smart_var_data_source
|
70
72
|
query = smart_var_data_source.smart_variables[var]
|
71
73
|
|
72
|
-
if query.is_a?
|
73
|
-
smart_var = query.map { |k,v| [v, k] }
|
74
|
-
elsif query.is_a?
|
74
|
+
if query.is_a?(Hash)
|
75
|
+
smart_var = query.map { |k, v| [v, k] }
|
76
|
+
elsif query.is_a?(Array)
|
75
77
|
smart_var = query.map { |v| [v, v] }
|
76
78
|
elsif query
|
77
79
|
result = smart_var_data_source.run_statement(query)
|
@@ -26,8 +26,15 @@ module Blazer
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def index
|
29
|
-
|
30
|
-
|
29
|
+
respond_to do |format|
|
30
|
+
format.html do
|
31
|
+
redirect_to root_path
|
32
|
+
end
|
33
|
+
format.json do
|
34
|
+
set_queries
|
35
|
+
render json: @queries
|
36
|
+
end
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
def new
|
@@ -225,6 +232,9 @@ module Blazer
|
|
225
232
|
|
226
233
|
def set_data_source
|
227
234
|
@data_source = Blazer.data_sources[params[:data_source]]
|
235
|
+
rescue Blazer::Error => e
|
236
|
+
raise unless e.message.start_with?("Unknown data source:")
|
237
|
+
render plain: "Unknown data source", status: :not_found
|
228
238
|
end
|
229
239
|
|
230
240
|
def continue_run
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% if @bind_vars.any? %>
|
2
2
|
<% var_params = request.query_parameters %>
|
3
|
-
|
3
|
+
<%= javascript_tag nonce: true do %>
|
4
4
|
<%= blazer_js_var "timeZone", Blazer.time_zone.tzinfo.name %>
|
5
5
|
var now = moment.tz(timeZone)
|
6
6
|
var format = "YYYY-MM-DD"
|
@@ -8,7 +8,7 @@
|
|
8
8
|
function toDate(time) {
|
9
9
|
return moment.tz(time.format(format), timeZone)
|
10
10
|
}
|
11
|
-
|
11
|
+
<% end %>
|
12
12
|
<form id="bind" method="get" action="<%= action %>" class="form-inline" style="margin-bottom: 15px;">
|
13
13
|
<% date_vars = ["start_time", "end_time"] %>
|
14
14
|
<% if (date_vars - @bind_vars).empty? %>
|
@@ -21,11 +21,11 @@
|
|
21
21
|
<%= label_tag var, var %>
|
22
22
|
<% if (data = @smart_vars[var]) %>
|
23
23
|
<%= select_tag var, options_for_select([[nil, nil]] + data, selected: var_params[var]), style: "margin-right: 20px; width: 200px; display: none;" %>
|
24
|
-
|
24
|
+
<%= javascript_tag nonce: true do %>
|
25
25
|
$("#<%= var %>").selectize({
|
26
26
|
create: true
|
27
27
|
});
|
28
|
-
|
28
|
+
<% end %>
|
29
29
|
<% elsif var.end_with?("_at") || var == "start_time" || var == "end_time" %>
|
30
30
|
<%= hidden_field_tag var, var_params[var] %>
|
31
31
|
|
@@ -35,7 +35,7 @@
|
|
35
35
|
</div>
|
36
36
|
</div>
|
37
37
|
|
38
|
-
|
38
|
+
<%= javascript_tag nonce: true do %>
|
39
39
|
(function() {
|
40
40
|
var input = $("#<%= var %>")
|
41
41
|
var datePicker = $("#<%= var %>-select")
|
@@ -57,7 +57,7 @@
|
|
57
57
|
datePicker.find("span").html(toDate(picker.startDate).format("MMMM D, YYYY"))
|
58
58
|
}
|
59
59
|
})()
|
60
|
-
|
60
|
+
<% end %>
|
61
61
|
<% else %>
|
62
62
|
<%= text_field_tag var, var_params[var], style: "width: 120px; margin-right: 20px;", autofocus: i == 0 && !var.end_with?("_at") && !var_params[var], class: "form-control" %>
|
63
63
|
<% end %>
|
@@ -75,7 +75,7 @@
|
|
75
75
|
</div>
|
76
76
|
</div>
|
77
77
|
|
78
|
-
|
78
|
+
<%= javascript_tag nonce: true do %>
|
79
79
|
function dateStr(daysAgo) {
|
80
80
|
return now.clone().subtract(daysAgo || 0, "days").format(format)
|
81
81
|
}
|
@@ -119,7 +119,7 @@
|
|
119
119
|
$("#reportrange").trigger("apply.daterangepicker", picker)
|
120
120
|
submitIfCompleted($("#start_time").closest("form"))
|
121
121
|
}
|
122
|
-
|
122
|
+
<% end %>
|
123
123
|
<% end %>
|
124
124
|
|
125
125
|
<input type="submit" class="btn btn-success" value="Run" style="vertical-align: top;" />
|
@@ -12,12 +12,12 @@
|
|
12
12
|
<div class="hide">
|
13
13
|
<%= f.select :query_id, [], {include_blank: true} %>
|
14
14
|
</div>
|
15
|
-
|
15
|
+
<%= javascript_tag nonce: true do %>
|
16
16
|
<%= blazer_js_var "queries", Blazer::Query.active.named.order(:name).select("id, name").map { |q| {text: q.name, value: q.id} } %>
|
17
17
|
<%= blazer_js_var "items", [@check.query_id].compact %>
|
18
18
|
|
19
19
|
$("#check_query_id").selectize({options: queries, items: items, highlight: false, maxOptions: 100}).parents(".hide").removeClass("hide");
|
20
|
-
|
20
|
+
<% end %>
|
21
21
|
</div>
|
22
22
|
|
23
23
|
<% if @check.respond_to?(:check_type) %>
|
@@ -28,9 +28,9 @@
|
|
28
28
|
<% check_options << ["Anomaly (most recent data point)", "anomaly"] if Blazer.anomaly_checks %>
|
29
29
|
<%= f.select :check_type, check_options %>
|
30
30
|
</div>
|
31
|
-
|
31
|
+
<%= javascript_tag nonce: true do %>
|
32
32
|
$("#check_check_type").selectize({}).parent().removeClass("hide");
|
33
|
-
|
33
|
+
<% end %>
|
34
34
|
</div>
|
35
35
|
<% elsif @check.respond_to?(:invert) %>
|
36
36
|
<div class="form-group">
|
@@ -38,9 +38,9 @@
|
|
38
38
|
<div class="hide">
|
39
39
|
<%= f.select :invert, [["Any results (bad data)", false], ["No results (missing data)", true]] %>
|
40
40
|
</div>
|
41
|
-
|
41
|
+
<%= javascript_tag nonce: true do %>
|
42
42
|
$("#check_invert").selectize({}).parent().removeClass("hide");
|
43
|
-
|
43
|
+
<% end %>
|
44
44
|
</div>
|
45
45
|
<% end %>
|
46
46
|
|
@@ -50,9 +50,9 @@
|
|
50
50
|
<div class="hide">
|
51
51
|
<%= f.select :schedule, Blazer.check_schedules.map { |v| [v, v] } %>
|
52
52
|
</div>
|
53
|
-
|
53
|
+
<%= javascript_tag nonce: true do %>
|
54
54
|
$("#check_schedule").selectize({}).parent().removeClass("hide");
|
55
|
-
|
55
|
+
<% end %>
|
56
56
|
</div>
|
57
57
|
<% end %>
|
58
58
|
|
@@ -62,11 +62,11 @@
|
|
62
62
|
</tbody>
|
63
63
|
</table>
|
64
64
|
|
65
|
-
|
65
|
+
<%= javascript_tag nonce: true do %>
|
66
66
|
$("#search").on("keyup", function() {
|
67
67
|
var value = $(this).val().toLowerCase()
|
68
68
|
$("#checks tbody tr").filter( function() {
|
69
69
|
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
70
70
|
})
|
71
71
|
}).focus()
|
72
|
-
|
72
|
+
<% end %>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
</p>
|
31
31
|
<% end %>
|
32
32
|
|
33
|
-
|
33
|
+
<%= javascript_tag nonce: true do %>
|
34
34
|
<%= blazer_js_var "queries", Blazer::Query.active.named.order(:name).select("id, name").map { |q| {text: q.name, value: q.id} } %>
|
35
35
|
<%= blazer_js_var "dashboardQueries", @queries || @dashboard.dashboard_queries.order(:position).map(&:query) %>
|
36
36
|
|
@@ -79,4 +79,4 @@
|
|
79
79
|
app.queries.splice(e.newIndex, 0, app.queries.splice(e.oldIndex, 1)[0])
|
80
80
|
}
|
81
81
|
})
|
82
|
-
|
82
|
+
<% end %>
|
@@ -38,7 +38,7 @@
|
|
38
38
|
<p class="text-muted">Loading...</p>
|
39
39
|
</div>
|
40
40
|
</div>
|
41
|
-
|
41
|
+
<%= javascript_tag nonce: true do %>
|
42
42
|
<% data = {statement: query.statement, query_id: query.id, data_source: query.data_source, variables: variable_params(query), only_chart: true} %>
|
43
43
|
<% data.merge!(cohort_period: params[:cohort_period]) if params[:cohort_period] %>
|
44
44
|
<%= blazer_js_var "data", data %>
|
@@ -49,5 +49,5 @@
|
|
49
49
|
}, function (message) {
|
50
50
|
$("#chart-<%= i %>").addClass("query-error").html(message)
|
51
51
|
});
|
52
|
-
|
52
|
+
<% end %>
|
53
53
|
<% end %>
|
@@ -68,7 +68,7 @@
|
|
68
68
|
</div>
|
69
69
|
</div>
|
70
70
|
|
71
|
-
|
71
|
+
<%= javascript_tag nonce: true do %>
|
72
72
|
<%= blazer_js_var "variableParams", @variable_params %>
|
73
73
|
<%= blazer_js_var "previewStatement", Blazer.data_sources.to_h { |k, v| [k, (v.preview_statement rescue "")] } %>
|
74
74
|
|
@@ -252,4 +252,4 @@
|
|
252
252
|
})
|
253
253
|
app.config.compilerOptions.whitespace = "preserve"
|
254
254
|
app.mount("#app")
|
255
|
-
|
255
|
+
<% end %>
|