blazer 2.2.7 → 2.4.1

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +119 -167
  4. data/app/assets/stylesheets/blazer/application.css +4 -0
  5. data/app/controllers/blazer/base_controller.rb +8 -0
  6. data/app/controllers/blazer/dashboards_controller.rb +3 -1
  7. data/app/controllers/blazer/queries_controller.rb +119 -3
  8. data/app/controllers/blazer/uploads_controller.rb +147 -0
  9. data/app/models/blazer/query.rb +9 -2
  10. data/app/models/blazer/upload.rb +11 -0
  11. data/app/models/blazer/uploads_connection.rb +7 -0
  12. data/app/views/blazer/_nav.html.erb +3 -0
  13. data/app/views/blazer/checks/_form.html.erb +1 -1
  14. data/app/views/blazer/checks/index.html.erb +3 -0
  15. data/app/views/blazer/dashboards/_form.html.erb +1 -1
  16. data/app/views/blazer/dashboards/show.html.erb +1 -1
  17. data/app/views/blazer/queries/_caching.html.erb +16 -0
  18. data/app/views/blazer/queries/_cohorts.html.erb +48 -0
  19. data/app/views/blazer/queries/docs.html.erb +6 -0
  20. data/app/views/blazer/queries/home.html.erb +3 -0
  21. data/app/views/blazer/queries/run.html.erb +15 -17
  22. data/app/views/blazer/queries/show.html.erb +1 -1
  23. data/app/views/blazer/uploads/_form.html.erb +27 -0
  24. data/app/views/blazer/uploads/edit.html.erb +3 -0
  25. data/app/views/blazer/uploads/index.html.erb +55 -0
  26. data/app/views/blazer/uploads/new.html.erb +3 -0
  27. data/config/routes.rb +5 -0
  28. data/lib/blazer.rb +22 -0
  29. data/lib/blazer/adapters/base_adapter.rb +8 -0
  30. data/lib/blazer/adapters/hive_adapter.rb +45 -0
  31. data/lib/blazer/adapters/spark_adapter.rb +9 -0
  32. data/lib/blazer/adapters/sql_adapter.rb +64 -1
  33. data/lib/blazer/data_source.rb +1 -1
  34. data/lib/blazer/version.rb +1 -1
  35. data/lib/generators/blazer/templates/config.yml.tt +6 -0
  36. data/lib/generators/blazer/templates/install.rb.tt +1 -0
  37. data/lib/generators/blazer/templates/uploads.rb.tt +10 -0
  38. data/lib/generators/blazer/uploads_generator.rb +18 -0
  39. data/lib/tasks/blazer.rake +9 -0
  40. metadata +20 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382b47b900346a570bb7e884eb28a8c4ce3df48c5db659bfa2dba161749ff6ea
4
- data.tar.gz: 64599ca3bbc9a06c5abcabc8249021d2611b3805b22518eb5b045a008de5347a
3
+ metadata.gz: b2a6413e7d7d49e280cbb8d6a880ec32c6c49452e69f980183b592bd927fa90a
4
+ data.tar.gz: 2e988e2010ae919dbfbb7c4c922753425b16eb0ee1e6fe309789cb44a450d8f7
5
5
  SHA512:
6
- metadata.gz: 565bfa960da08efa1d152c54e3f9ca1c7d2cbf6ada4e1464849c88dae33e2423fb5884366f4a6c1bab66b53acdd874e5d1033bb28c34e67f1d5930e5e47bfeda
7
- data.tar.gz: a802b1465b213bd39645259b240011df0e8bc3feef7c3664771fb35b8243f9d183f0e8897e48120d85be3bea5dfe99e127d40b468acffd2b0a0d2208b2fc98ea
6
+ metadata.gz: 50fc2e2d4c430935e05d14df65aea648df86c4792e58007ff0f6015a5c58a5842db4f9d22d430ac7f84b094325d45c41406f67676d6ec3d3535266e47ebd53a0
7
+ data.tar.gz: 3118830b6ab4198fe383615c09319d98619480e2f88dca117b92e99c228da82a5556f7a9948ad57dd45e788cacc20efec370e0eb68770919e5dab9909bd4f1ef
@@ -1,3 +1,28 @@
1
+ ## 2.4.1 (2021-01-25)
2
+
3
+ - Added cohorts for MySQL
4
+ - Added support for Apache Hive and Apache Spark
5
+ - Fixed deprecation warning with Active Record 6.1
6
+
7
+ ## 2.4.0 (2020-12-15)
8
+
9
+ - Added cohorts
10
+ - Fixed broken routes for some applications
11
+ - Forecasting and uploads are no longer experimental
12
+
13
+ ## 2.3.1 (2020-11-23)
14
+
15
+ - Improved column names for uploads
16
+
17
+ ## 2.3.0 (2020-11-16)
18
+
19
+ - Added support for archiving queries
20
+ - Added experimental support for uploads
21
+
22
+ ## 2.2.8 (2020-11-01)
23
+
24
+ - Fixed error when deleting dashboard
25
+
1
26
  ## 2.2.7 (2020-09-07)
2
27
 
3
28
  - Use `datetime` type in migration
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
 
@@ -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,8 @@ 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 Spark](#apache-spark)
495
571
  - [Cassandra](#cassandra)
496
572
  - [Druid](#druid)
497
573
  - [Elasticsearch](#elasticsearch)
@@ -553,6 +629,32 @@ data_sources:
553
629
  url: http://hostname:8047
554
630
  ```
555
631
 
632
+ ### Apache Hive
633
+
634
+ Add [hexspace](https://github.com/ankane/hexspace) to your Gemfile and set:
635
+
636
+ ```yml
637
+ data_sources:
638
+ my_source:
639
+ adapter: hive
640
+ url: sasl://user:password@hostname:10000/database
641
+ ```
642
+
643
+ Use a read-only user. Requires [HiveServer2](https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2).
644
+
645
+ ### Apache Spark
646
+
647
+ Add [hexspace](https://github.com/ankane/hexspace) to your Gemfile and set:
648
+
649
+ ```yml
650
+ data_sources:
651
+ my_source:
652
+ adapter: spark
653
+ url: sasl://user:password@hostname:10000/database
654
+ ```
655
+
656
+ Use a read-only user. Requires the [Thrift server](https://spark.apache.org/docs/latest/sql-distributed-sql-engine.html).
657
+
556
658
  ### Cassandra
557
659
 
558
660
  Add [cassandra-driver](https://github.com/datastax/ruby-driver) to your Gemfile and set:
@@ -609,8 +711,6 @@ data_sources:
609
711
 
610
712
  ### InfluxDB
611
713
 
612
- *Experimental*
613
-
614
714
  Add [influxdb](https://github.com/influxdata/influxdb-ruby) to your Gemfile and set:
615
715
 
616
716
  ```yml
@@ -644,8 +744,6 @@ data_sources:
644
744
 
645
745
  ### Neo4j
646
746
 
647
- *Experimental*
648
-
649
747
  Add [neo4j-core](https://github.com/neo4jrb/neo4j-core) to your Gemfile and set:
650
748
 
651
749
  ```yml
@@ -687,8 +785,6 @@ data_sources:
687
785
 
688
786
  ### Salesforce
689
787
 
690
- *Experimental*
691
-
692
788
  Add [restforce](https://github.com/restforce/restforce) to your Gemfile and set:
693
789
 
694
790
  ```yml
@@ -712,8 +808,6 @@ Supports [SOQL](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta
712
808
 
713
809
  ### Socrata Open Data API (SODA)
714
810
 
715
- *Experimental*
716
-
717
811
  Set:
718
812
 
719
813
  ```yml
@@ -836,25 +930,14 @@ async: true
836
930
  config.cache_store = :mem_cache_store
837
931
  ```
838
932
 
839
- ## Anomaly Detection on Heroku
933
+ ## Archiving
840
934
 
841
- Add the [R buildpack](https://github.com/virtualstaticvoid/heroku-buildpack-r) to your app.
935
+ Archive queries that haven’t been viewed in over 90 days.
842
936
 
843
937
  ```sh
844
- heroku buildpacks:add --index 1 https://github.com/virtualstaticvoid/heroku-buildpack-r.git
845
- ```
846
-
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
- }
938
+ rake blazer:archive_queries
854
939
  ```
855
940
 
856
- Commit and deploy away. The first deploy may take a few minutes.
857
-
858
941
  ## Content Security Policy
859
942
 
860
943
  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 +948,33 @@ override_csp: true
865
948
 
866
949
  ## Upgrading
867
950
 
868
- ### 2.0
869
-
870
- To use Slack notifications, create a migration
871
-
872
- ```sh
873
- rails g migration add_slack_channels_to_blazer_checks
874
- ```
875
-
876
- with:
877
-
878
- ```ruby
879
- add_column :blazer_checks, :slack_channels, :text
880
- ```
881
-
882
- ### 1.5
951
+ ### 2.3
883
952
 
884
- To take advantage of the anomaly detection, create a migration
953
+ To archive queries, create a migration
885
954
 
886
955
  ```sh
887
- rails g migration upgrade_blazer_to_1_5
956
+ rails g migration add_status_to_blazer_queries
888
957
  ```
889
958
 
890
959
  with:
891
960
 
892
961
  ```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
962
+ add_column :blazer_queries, :status, :string
963
+ Blazer::Query.update_all(status: "active")
909
964
  ```
910
965
 
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
- ```
966
+ ### 2.0
937
967
 
938
- Create a migration
968
+ To use Slack notifications, create a migration
939
969
 
940
970
  ```sh
941
- rails g migration upgrade_blazer_to_1_0
971
+ rails g migration add_slack_channels_to_blazer_checks
942
972
  ```
943
973
 
944
974
  with:
945
975
 
946
976
  ```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
977
+ add_column :blazer_checks, :slack_channels, :text
1026
978
  ```
1027
979
 
1028
980
  ## History
@@ -16,6 +16,10 @@ body {
16
16
  padding-bottom: 15px;
17
17
  }
18
18
 
19
+ table.results-table {
20
+ margin-bottom: 0;
21
+ }
22
+
19
23
  .results-table th {
20
24
  cursor: pointer;
21
25
  }