blazer 2.2.8 → 2.4.2

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.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +131 -168
  5. data/app/assets/stylesheets/blazer/application.css +4 -0
  6. data/app/controllers/blazer/base_controller.rb +8 -0
  7. data/app/controllers/blazer/dashboards_controller.rb +2 -0
  8. data/app/controllers/blazer/queries_controller.rb +119 -3
  9. data/app/controllers/blazer/uploads_controller.rb +147 -0
  10. data/app/models/blazer/query.rb +9 -2
  11. data/app/models/blazer/upload.rb +11 -0
  12. data/app/models/blazer/uploads_connection.rb +7 -0
  13. data/app/views/blazer/_nav.html.erb +3 -0
  14. data/app/views/blazer/checks/_form.html.erb +1 -1
  15. data/app/views/blazer/checks/index.html.erb +3 -0
  16. data/app/views/blazer/dashboards/_form.html.erb +1 -1
  17. data/app/views/blazer/dashboards/show.html.erb +1 -1
  18. data/app/views/blazer/queries/_caching.html.erb +16 -0
  19. data/app/views/blazer/queries/_cohorts.html.erb +48 -0
  20. data/app/views/blazer/queries/docs.html.erb +6 -0
  21. data/app/views/blazer/queries/home.html.erb +3 -0
  22. data/app/views/blazer/queries/run.html.erb +15 -17
  23. data/app/views/blazer/queries/show.html.erb +1 -1
  24. data/app/views/blazer/uploads/_form.html.erb +27 -0
  25. data/app/views/blazer/uploads/edit.html.erb +3 -0
  26. data/app/views/blazer/uploads/index.html.erb +55 -0
  27. data/app/views/blazer/uploads/new.html.erb +3 -0
  28. data/config/routes.rb +5 -0
  29. data/lib/blazer.rb +24 -0
  30. data/lib/blazer/adapters/base_adapter.rb +8 -0
  31. data/lib/blazer/adapters/druid_adapter.rb +3 -3
  32. data/lib/blazer/adapters/hive_adapter.rb +45 -0
  33. data/lib/blazer/adapters/ignite_adapter.rb +54 -0
  34. data/lib/blazer/adapters/spark_adapter.rb +9 -0
  35. data/lib/blazer/adapters/sql_adapter.rb +64 -1
  36. data/lib/blazer/data_source.rb +2 -2
  37. data/lib/blazer/version.rb +1 -1
  38. data/lib/generators/blazer/templates/config.yml.tt +6 -0
  39. data/lib/generators/blazer/templates/install.rb.tt +1 -0
  40. data/lib/generators/blazer/templates/uploads.rb.tt +10 -0
  41. data/lib/generators/blazer/uploads_generator.rb +18 -0
  42. data/lib/tasks/blazer.rake +9 -0
  43. metadata +18 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4289e0500fd1a7576f07fb77fc69e8c35e07b622283e757731048e2c6aacf975
4
- data.tar.gz: 743d90a4d483cffd37e89a5b5d6299385b558481db8756a5c48b310850dfc58a
3
+ metadata.gz: 8c8356dddcf7221e7bbf93eb4cc4d1e1b7804f08c29dd57006517d0e157f1ff4
4
+ data.tar.gz: 7ac1354b00daa9905901a6c11c6e8a948962e2c6830feeaa19d065bfa1bde9a6
5
5
  SHA512:
6
- metadata.gz: 0de93b666eaf3212e9e6069ed85359068afb4d46952f9bd4cc363f065571d82b2c4cd9c3e8cf8be45cb530585971b1f01d3617b188faa7b9db6f1db322cf14a7
7
- data.tar.gz: 617672bf28e0e9692d934a0e5446607a4fcd925f8ce41e47e384c2e8d7b57baacf5f58dc4271101dbedd849b4fad1032bdc097ee02a69bf7612721ce2ef29428
6
+ metadata.gz: 5959df81b7c5dbe0b608bfe565f1d98d2a7119a6309bbf934d86d1154227cd6315051ec131c9e8a8d9641022468c42724152620b4a226ee8300791d1095df858
7
+ data.tar.gz: 694140d5e5fe1904f16ccbcd95f9e18b8fcd54e7630d0df05637ddc977ab223220cb749798c8d365d77f962b131a91135bcfa9c12dc4d849f3d4caea1a642f79
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## 2.4.2 (2021-02-08)
2
+
3
+ - Added support for Apache Ignite
4
+
5
+ ## 2.4.1 (2021-01-25)
6
+
7
+ - Added cohorts for MySQL
8
+ - Added support for Apache Hive and Apache Spark
9
+ - Fixed deprecation warning with Active Record 6.1
10
+
11
+ ## 2.4.0 (2020-12-15)
12
+
13
+ - Added cohorts
14
+ - Fixed broken routes for some applications
15
+ - Forecasting and uploads are no longer experimental
16
+
17
+ ## 2.3.1 (2020-11-23)
18
+
19
+ - Improved column names for uploads
20
+
21
+ ## 2.3.0 (2020-11-16)
22
+
23
+ - Added support for archiving queries
24
+ - Added experimental support for uploads
25
+
1
26
  ## 2.2.8 (2020-11-01)
2
27
 
3
28
  - Fixed error when deleting dashboard
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2020 Andrew Kane
1
+ Copyright (c) 2014-2021 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ 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
- [![Screenshot](https://blazer.dokkuapp.com/assets/blazer-90bd7acc9fdf1f5fc2bb25bfe5506f746ec8c9d2e0730388debfd697e32f75b8.png)](https://blazer.dokkuapp.com)
7
+ [![Screenshot](https://blazer.dokkuapp.com/assets/blazer-a10baa40fef1ca2f5bb25fc97bcf261a6a54192fb1ad0f893c0f562b8c7c4697.png)](https://blazer.dokkuapp.com)
8
8
 
9
9
  Blazer is also available as a [Docker image](https://github.com/ankane/blazer-docker).
10
10
 
@@ -25,6 +25,12 @@ Blazer is also available as a [Docker image](https://github.com/ankane/blazer-do
25
25
  - [Charts](#charts)
26
26
  - [Dashboards](#dashboards)
27
27
  - [Checks](#checks)
28
+ - [Cohorts](#cohorts)
29
+ - [Anomaly Detection](#anomaly-detection)
30
+ - [Forecasting](#forecasting)
31
+ - [Uploads](#uploads)
32
+ - [Data Sources](#data-sources)
33
+ - [Query Permissions](#query-permissions)
28
34
 
29
35
  ## Installation
30
36
 
@@ -53,7 +59,7 @@ For production, specify your database:
53
59
  ENV["BLAZER_DATABASE_URL"] = "postgres://user:password@hostname:5432/database"
54
60
  ```
55
61
 
56
- Blazer tries to protect against queries which modify data (by running each query in a transaction and rolling it back), but a safer approach is to use a read only user. [See how to create one](#permissions).
62
+ Blazer tries to protect against queries which modify data (by running each query in a transaction and rolling it back), but a safer approach is to use a read-only user. [See how to create one](#permissions).
57
63
 
58
64
  #### Checks (optional)
59
65
 
@@ -383,6 +389,31 @@ SELECT * FROM ratings WHERE user_id IS NULL /* all ratings should have a user */
383
389
 
384
390
  Then create check with optional emails if you want to be notified. Emails are sent when a check starts failing, and when it starts passing again.
385
391
 
392
+ ## Cohorts
393
+
394
+ Create a cohort analysis from a simple SQL query. [Example](https://blazer.dokkuapp.com/queries/19-cohort-analysis-from-first-order)
395
+
396
+ Create a query with the comment `/* cohort analysis */`. The result should have columns named `user_id` and `conversion_time` and optionally `cohort_time`.
397
+
398
+ You can generate cohorts from the first conversion time:
399
+
400
+ ```sql
401
+ /* cohort analysis */
402
+ SELECT user_id, created_at AS conversion_time FROM orders
403
+ ```
404
+
405
+ (the first conversion isn’t counted in the first time period with this format)
406
+
407
+ Or from another time, like sign up:
408
+
409
+ ```sql
410
+ /* cohort analysis */
411
+ SELECT users.id AS user_id, orders.created_at AS conversion_time, users.created_at AS cohort_time
412
+ FROM users LEFT JOIN orders ON orders.user_id = users.id
413
+ ```
414
+
415
+ This feature requires PostgreSQL or MySQL.
416
+
386
417
  ## Anomaly Detection
387
418
 
388
419
  Blazer supports two different approaches to anomaly detection.
@@ -428,16 +459,33 @@ anomaly_checks: r
428
459
 
429
460
  If upgrading from version 1.4 or below, also follow the [upgrade instructions](#15).
430
461
 
431
- If you’re on Heroku, follow [these additional instructions](#anomaly-detection-on-heroku).
462
+ If you’re on Heroku, follow the additional instructions below.
463
+
464
+ ### R on Heroku
465
+
466
+ Add the [R buildpack](https://github.com/virtualstaticvoid/heroku-buildpack-r) to your app.
467
+
468
+ ```sh
469
+ heroku buildpacks:add --index 1 https://github.com/virtualstaticvoid/heroku-buildpack-r.git
470
+ ```
471
+
472
+ And create an `init.R` with:
473
+
474
+ ```r
475
+ if (!"AnomalyDetection" %in% installed.packages()) {
476
+ install.packages("remotes")
477
+ remotes::install_github("twitter/AnomalyDetection")
478
+ }
479
+ ```
480
+
481
+ Commit and deploy away. The first deploy may take a few minutes.
432
482
 
433
483
  ## Forecasting
434
484
 
435
- Blazer has experimental support for two different forecasting methods.
485
+ Blazer supports for two different forecasting methods. [Example](https://blazer.dokkuapp.com/queries/18-forecast?forecast=t)
436
486
 
437
487
  A forecast link will appear for queries that return 2 columns with types timestamp and numeric.
438
488
 
439
- [Example](https://blazer.dokkuapp.com/queries/18-forecast?forecast=t)
440
-
441
489
  ### Prophet
442
490
 
443
491
  Add [prophet](https://github.com/ankane/prophet) to your Gemfile:
@@ -468,6 +516,32 @@ And add to `config/blazer.yml`:
468
516
  forecasting: trend
469
517
  ```
470
518
 
519
+ ## Uploads
520
+
521
+ Creating database tables from CSV files. [Example](https://blazer.dokkuapp.com/uploads)
522
+
523
+ Run:
524
+
525
+ ```sh
526
+ rails generate blazer:uploads
527
+ rails db:migrate
528
+ ```
529
+
530
+ And add to `config/blazer.yml`:
531
+
532
+ ```yml
533
+ uploads:
534
+ url: postgres://...
535
+ schema: uploads
536
+ data_source: main
537
+ ```
538
+
539
+ This feature requires PostgreSQL. Create a new schema just for uploads.
540
+
541
+ ```sql
542
+ CREATE SCHEMA uploads;
543
+ ```
544
+
471
545
  ## Data Sources
472
546
 
473
547
  Blazer supports multiple data sources :tada:
@@ -492,6 +566,9 @@ data_sources:
492
566
  - [Amazon Athena](#amazon-athena)
493
567
  - [Amazon Redshift](#amazon-redshift)
494
568
  - [Apache Drill](#apache-drill)
569
+ - [Apache Hive](#apache-hive)
570
+ - [Apache Ignite](#apache-ignite) [master]
571
+ - [Apache Spark](#apache-spark)
495
572
  - [Cassandra](#cassandra)
496
573
  - [Druid](#druid)
497
574
  - [Elasticsearch](#elasticsearch)
@@ -553,6 +630,42 @@ data_sources:
553
630
  url: http://hostname:8047
554
631
  ```
555
632
 
633
+ ### Apache Hive
634
+
635
+ Add [hexspace](https://github.com/ankane/hexspace) to your Gemfile and set:
636
+
637
+ ```yml
638
+ data_sources:
639
+ my_source:
640
+ adapter: hive
641
+ url: sasl://user:password@hostname:10000/database
642
+ ```
643
+
644
+ Use a [read-only user](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Authorization). Requires [HiveServer2](https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2).
645
+
646
+ ### Apache Ignite
647
+
648
+ Add [ignite-client](https://github.com/ankane/ignite-ruby) to your Gemfile and set:
649
+
650
+ ```yml
651
+ data_sources:
652
+ my_source:
653
+ url: ignite://user:password@hostname:10800
654
+ ```
655
+
656
+ ### Apache Spark
657
+
658
+ Add [hexspace](https://github.com/ankane/hexspace) to your Gemfile and set:
659
+
660
+ ```yml
661
+ data_sources:
662
+ my_source:
663
+ adapter: spark
664
+ url: sasl://user:password@hostname:10000/database
665
+ ```
666
+
667
+ Use a read-only user. Requires the [Thrift server](https://spark.apache.org/docs/latest/sql-distributed-sql-engine.html).
668
+
556
669
  ### Cassandra
557
670
 
558
671
  Add [cassandra-driver](https://github.com/datastax/ruby-driver) to your Gemfile and set:
@@ -609,8 +722,6 @@ data_sources:
609
722
 
610
723
  ### InfluxDB
611
724
 
612
- *Experimental*
613
-
614
725
  Add [influxdb](https://github.com/influxdata/influxdb-ruby) to your Gemfile and set:
615
726
 
616
727
  ```yml
@@ -644,8 +755,6 @@ data_sources:
644
755
 
645
756
  ### Neo4j
646
757
 
647
- *Experimental*
648
-
649
758
  Add [neo4j-core](https://github.com/neo4jrb/neo4j-core) to your Gemfile and set:
650
759
 
651
760
  ```yml
@@ -687,8 +796,6 @@ data_sources:
687
796
 
688
797
  ### Salesforce
689
798
 
690
- *Experimental*
691
-
692
799
  Add [restforce](https://github.com/restforce/restforce) to your Gemfile and set:
693
800
 
694
801
  ```yml
@@ -712,8 +819,6 @@ Supports [SOQL](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta
712
819
 
713
820
  ### Socrata Open Data API (SODA)
714
821
 
715
- *Experimental*
716
-
717
822
  Set:
718
823
 
719
824
  ```yml
@@ -836,25 +941,14 @@ async: true
836
941
  config.cache_store = :mem_cache_store
837
942
  ```
838
943
 
839
- ## Anomaly Detection on Heroku
944
+ ## Archiving
840
945
 
841
- Add the [R buildpack](https://github.com/virtualstaticvoid/heroku-buildpack-r) to your app.
946
+ Archive queries that haven’t been viewed in over 90 days.
842
947
 
843
948
  ```sh
844
- heroku buildpacks:add --index 1 https://github.com/virtualstaticvoid/heroku-buildpack-r.git
949
+ rake blazer:archive_queries
845
950
  ```
846
951
 
847
- And create an `init.R` with:
848
-
849
- ```r
850
- if (!"AnomalyDetection" %in% installed.packages()) {
851
- install.packages("remotes")
852
- remotes::install_github("twitter/AnomalyDetection")
853
- }
854
- ```
855
-
856
- Commit and deploy away. The first deploy may take a few minutes.
857
-
858
952
  ## Content Security Policy
859
953
 
860
954
  If views are stuck with a `Loading...` message, there might be a problem with strict CSP settings in your app. This can be checked with Firefox or Chrome dev tools. You can allow Blazer to override these settings for its controllers with:
@@ -865,164 +959,33 @@ override_csp: true
865
959
 
866
960
  ## Upgrading
867
961
 
868
- ### 2.0
962
+ ### 2.3
869
963
 
870
- To use Slack notifications, create a migration
964
+ To archive queries, create a migration
871
965
 
872
966
  ```sh
873
- rails g migration add_slack_channels_to_blazer_checks
967
+ rails g migration add_status_to_blazer_queries
874
968
  ```
875
969
 
876
970
  with:
877
971
 
878
972
  ```ruby
879
- add_column :blazer_checks, :slack_channels, :text
880
- ```
881
-
882
- ### 1.5
883
-
884
- To take advantage of the anomaly detection, create a migration
885
-
886
- ```sh
887
- rails g migration upgrade_blazer_to_1_5
973
+ add_column :blazer_queries, :status, :string
974
+ Blazer::Query.update_all(status: "active")
888
975
  ```
889
976
 
890
- with:
891
-
892
- ```ruby
893
- add_column :blazer_checks, :check_type, :string
894
- add_column :blazer_checks, :message, :text
895
- commit_db_transaction
896
-
897
- Blazer::Check.reset_column_information
898
-
899
- Blazer::Check.where(invert: true).update_all(check_type: "missing_data")
900
- Blazer::Check.where(check_type: nil).update_all(check_type: "bad_data")
901
- ```
902
-
903
- ### 1.3
904
-
905
- To take advantage of the latest features, create a migration
906
-
907
- ```sh
908
- rails g migration upgrade_blazer_to_1_3
909
- ```
910
-
911
- with:
912
-
913
- ```ruby
914
- add_column :blazer_dashboards, :creator_id, :integer
915
- add_column :blazer_checks, :creator_id, :integer
916
- add_column :blazer_checks, :invert, :boolean
917
- add_column :blazer_checks, :schedule, :string
918
- add_column :blazer_checks, :last_run_at, :timestamp
919
- commit_db_transaction
920
-
921
- Blazer::Check.update_all schedule: "1 hour"
922
- ```
923
-
924
- ### 1.0
925
-
926
- Blazer 1.0 brings a number of new features:
927
-
928
- - multiple data sources, including Redshift
929
- - dashboards
930
- - checks
931
-
932
- To upgrade, run:
933
-
934
- ```sh
935
- bundle update blazer
936
- ```
977
+ ### 2.0
937
978
 
938
- Create a migration
979
+ To use Slack notifications, create a migration
939
980
 
940
981
  ```sh
941
- rails g migration upgrade_blazer_to_1_0
982
+ rails g migration add_slack_channels_to_blazer_checks
942
983
  ```
943
984
 
944
985
  with:
945
986
 
946
987
  ```ruby
947
- add_column :blazer_queries, :data_source, :string
948
- add_column :blazer_audits, :data_source, :string
949
-
950
- create_table :blazer_dashboards do |t|
951
- t.text :name
952
- t.timestamps
953
- end
954
-
955
- create_table :blazer_dashboard_queries do |t|
956
- t.references :dashboard
957
- t.references :query
958
- t.integer :position
959
- t.timestamps
960
- end
961
-
962
- create_table :blazer_checks do |t|
963
- t.references :query
964
- t.string :state
965
- t.text :emails
966
- t.timestamps
967
- end
968
- ```
969
-
970
- And run:
971
-
972
- ```sh
973
- rails db:migrate
974
- ```
975
-
976
- Update `config/blazer.yml` with:
977
-
978
- ```yml
979
- # see https://github.com/ankane/blazer for more info
980
-
981
- data_sources:
982
- main:
983
- url: <%= ENV["BLAZER_DATABASE_URL"] %>
984
-
985
- # statement timeout, in seconds
986
- # applies to PostgreSQL only
987
- # none by default
988
- # timeout: 15
989
-
990
- # time to cache results, in minutes
991
- # can greatly improve speed
992
- # none by default
993
- # cache: 60
994
-
995
- # wrap queries in a transaction for safety
996
- # not necessary if you use a read-only user
997
- # true by default
998
- # use_transaction: false
999
-
1000
- smart_variables:
1001
- # zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
1002
-
1003
- linked_columns:
1004
- # user_id: "/admin/users/{value}"
1005
-
1006
- smart_columns:
1007
- # user_id: "SELECT id, name FROM users WHERE id IN {value}"
1008
-
1009
- # create audits
1010
- audit: true
1011
-
1012
- # change the time zone
1013
- # time_zone: "Pacific Time (US & Canada)"
1014
-
1015
- # class name of the user model
1016
- # user_class: User
1017
-
1018
- # method name for the current user
1019
- # user_method: current_user
1020
-
1021
- # method name for the display name
1022
- # user_name: name
1023
-
1024
- # email to send checks from
1025
- # from_email: blazer@example.org
988
+ add_column :blazer_checks, :slack_channels, :text
1026
989
  ```
1027
990
 
1028
991
  ## History