sql-jarvis 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/CHANGELOG.md +228 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +775 -0
  7. data/Rakefile +1 -0
  8. data/app/assets/fonts/blazer/glyphicons-halflings-regular.eot +0 -0
  9. data/app/assets/fonts/blazer/glyphicons-halflings-regular.svg +288 -0
  10. data/app/assets/fonts/blazer/glyphicons-halflings-regular.ttf +0 -0
  11. data/app/assets/fonts/blazer/glyphicons-halflings-regular.woff +0 -0
  12. data/app/assets/fonts/blazer/glyphicons-halflings-regular.woff2 +0 -0
  13. data/app/assets/javascripts/blazer/Chart.js +14145 -0
  14. data/app/assets/javascripts/blazer/Sortable.js +1144 -0
  15. data/app/assets/javascripts/blazer/ace.js +6 -0
  16. data/app/assets/javascripts/blazer/ace/ace.js +11 -0
  17. data/app/assets/javascripts/blazer/ace/ext-language_tools.js +5 -0
  18. data/app/assets/javascripts/blazer/ace/mode-sql.js +1 -0
  19. data/app/assets/javascripts/blazer/ace/snippets/sql.js +1 -0
  20. data/app/assets/javascripts/blazer/ace/snippets/text.js +1 -0
  21. data/app/assets/javascripts/blazer/ace/theme-twilight.js +1 -0
  22. data/app/assets/javascripts/blazer/application.js +79 -0
  23. data/app/assets/javascripts/blazer/bootstrap.js +2366 -0
  24. data/app/assets/javascripts/blazer/chartkick.js +1693 -0
  25. data/app/assets/javascripts/blazer/daterangepicker.js +1505 -0
  26. data/app/assets/javascripts/blazer/fuzzysearch.js +24 -0
  27. data/app/assets/javascripts/blazer/highlight.pack.js +1 -0
  28. data/app/assets/javascripts/blazer/jquery.js +10308 -0
  29. data/app/assets/javascripts/blazer/jquery.stickytableheaders.js +263 -0
  30. data/app/assets/javascripts/blazer/jquery_ujs.js +469 -0
  31. data/app/assets/javascripts/blazer/moment-timezone.js +1007 -0
  32. data/app/assets/javascripts/blazer/moment.js +3043 -0
  33. data/app/assets/javascripts/blazer/queries.js +110 -0
  34. data/app/assets/javascripts/blazer/routes.js +23 -0
  35. data/app/assets/javascripts/blazer/selectize.js +3667 -0
  36. data/app/assets/javascripts/blazer/stupidtable.js +114 -0
  37. data/app/assets/javascripts/blazer/vue.js +7515 -0
  38. data/app/assets/stylesheets/blazer/application.css +198 -0
  39. data/app/assets/stylesheets/blazer/bootstrap.css.erb +6202 -0
  40. data/app/assets/stylesheets/blazer/daterangepicker-bs3.css +375 -0
  41. data/app/assets/stylesheets/blazer/github.css +125 -0
  42. data/app/assets/stylesheets/blazer/selectize.default.css +387 -0
  43. data/app/controllers/blazer/base_controller.rb +103 -0
  44. data/app/controllers/blazer/checks_controller.rb +56 -0
  45. data/app/controllers/blazer/dashboards_controller.rb +105 -0
  46. data/app/controllers/blazer/queries_controller.rb +325 -0
  47. data/app/helpers/blazer/base_helper.rb +57 -0
  48. data/app/mailers/blazer/check_mailer.rb +27 -0
  49. data/app/models/blazer/audit.rb +6 -0
  50. data/app/models/blazer/check.rb +95 -0
  51. data/app/models/blazer/connection.rb +5 -0
  52. data/app/models/blazer/dashboard.rb +13 -0
  53. data/app/models/blazer/dashboard_query.rb +9 -0
  54. data/app/models/blazer/query.rb +31 -0
  55. data/app/models/blazer/record.rb +5 -0
  56. data/app/views/blazer/_nav.html.erb +16 -0
  57. data/app/views/blazer/_variables.html.erb +102 -0
  58. data/app/views/blazer/check_mailer/failing_checks.html.erb +6 -0
  59. data/app/views/blazer/check_mailer/state_change.html.erb +47 -0
  60. data/app/views/blazer/checks/_form.html.erb +71 -0
  61. data/app/views/blazer/checks/edit.html.erb +1 -0
  62. data/app/views/blazer/checks/index.html.erb +40 -0
  63. data/app/views/blazer/checks/new.html.erb +1 -0
  64. data/app/views/blazer/dashboards/_form.html.erb +76 -0
  65. data/app/views/blazer/dashboards/edit.html.erb +1 -0
  66. data/app/views/blazer/dashboards/new.html.erb +1 -0
  67. data/app/views/blazer/dashboards/show.html.erb +47 -0
  68. data/app/views/blazer/queries/_form.html.erb +240 -0
  69. data/app/views/blazer/queries/edit.html.erb +2 -0
  70. data/app/views/blazer/queries/home.html.erb +152 -0
  71. data/app/views/blazer/queries/new.html.erb +2 -0
  72. data/app/views/blazer/queries/run.html.erb +163 -0
  73. data/app/views/blazer/queries/schema.html.erb +18 -0
  74. data/app/views/blazer/queries/show.html.erb +73 -0
  75. data/app/views/layouts/blazer/application.html.erb +24 -0
  76. data/blazer.gemspec +26 -0
  77. data/config/routes.rb +16 -0
  78. data/lib/blazer.rb +185 -0
  79. data/lib/blazer/adapters/athena_adapter.rb +128 -0
  80. data/lib/blazer/adapters/base_adapter.rb +53 -0
  81. data/lib/blazer/adapters/bigquery_adapter.rb +67 -0
  82. data/lib/blazer/adapters/drill_adapter.rb +28 -0
  83. data/lib/blazer/adapters/elasticsearch_adapter.rb +49 -0
  84. data/lib/blazer/adapters/mongodb_adapter.rb +39 -0
  85. data/lib/blazer/adapters/presto_adapter.rb +45 -0
  86. data/lib/blazer/adapters/sql_adapter.rb +182 -0
  87. data/lib/blazer/data_source.rb +193 -0
  88. data/lib/blazer/detect_anomalies.R +19 -0
  89. data/lib/blazer/engine.rb +47 -0
  90. data/lib/blazer/result.rb +170 -0
  91. data/lib/blazer/run_statement.rb +40 -0
  92. data/lib/blazer/run_statement_job.rb +21 -0
  93. data/lib/blazer/version.rb +3 -0
  94. data/lib/generators/blazer/install_generator.rb +39 -0
  95. data/lib/generators/blazer/templates/config.yml +62 -0
  96. data/lib/generators/blazer/templates/install.rb +45 -0
  97. data/lib/tasks/blazer.rake +10 -0
  98. metadata +211 -0
@@ -0,0 +1,21 @@
1
+ require "sucker_punch"
2
+
3
+ module Blazer
4
+ class RunStatementJob
5
+ include SuckerPunch::Job
6
+ workers 4
7
+
8
+ def perform(result, data_source, statement, options)
9
+ begin
10
+ ActiveRecord::Base.connection_pool.with_connection do
11
+ result << Blazer::RunStatement.new.perform(data_source, statement, options)
12
+ end
13
+ rescue Exception => e
14
+ result.clear
15
+ result << Blazer::Result.new(data_source, [], [], "Unknown error", nil, false)
16
+ Blazer.cache.write(data_source.run_cache_key(options[:run_id]), Marshal.dump([[], [], "Unknown error", nil]), expires_in: 30.seconds)
17
+ raise e
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Blazer
2
+ VERSION = "1.8.0"
3
+ end
@@ -0,0 +1,39 @@
1
+ # taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
2
+ require "rails/generators"
3
+ require "rails/generators/migration"
4
+ require "active_record"
5
+ require "rails/generators/active_record"
6
+
7
+ module Blazer
8
+ module Generators
9
+ class InstallGenerator < Rails::Generators::Base
10
+ include Rails::Generators::Migration
11
+
12
+ source_root File.expand_path("../templates", __FILE__)
13
+
14
+ # Implement the required interface for Rails::Generators::Migration.
15
+ def self.next_migration_number(dirname) #:nodoc:
16
+ next_migration_number = current_migration_number(dirname) + 1
17
+ if ActiveRecord::Base.timestamped_migrations
18
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
19
+ else
20
+ "%.3d" % next_migration_number
21
+ end
22
+ end
23
+
24
+ def copy_migration
25
+ migration_template "install.rb", "db/migrate/install_blazer.rb", migration_version: migration_version
26
+ end
27
+
28
+ def copy_config
29
+ template "config.yml", "config/blazer.yml"
30
+ end
31
+
32
+ def migration_version
33
+ if ActiveRecord::VERSION::MAJOR >= 5
34
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,62 @@
1
+ # see https://github.com/ankane/blazer for more info
2
+
3
+ data_sources:
4
+ main:
5
+ url: <%%= ENV["BLAZER_DATABASE_URL"] %>
6
+ mapbox_access_token: <%%= ENV["MAPBOX_ACCESS_TOKEN"] %>
7
+
8
+ # statement timeout, in seconds
9
+ # none by default
10
+ # timeout: 15
11
+
12
+ # caching settings
13
+ # can greatly improve speed
14
+ # off by default
15
+ # cache:
16
+ # mode: slow # or all
17
+ # expires_in: 60 # min
18
+ # slow_threshold: 15 # sec, only used in slow mode
19
+
20
+ # wrap queries in a transaction for safety
21
+ # not necessary if you use a read-only user
22
+ # true by default
23
+ # use_transaction: false
24
+
25
+ smart_variables:
26
+ # zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
27
+ # period: ["day", "week", "month"]
28
+ # status: {0: "Active", 1: "Archived"}
29
+
30
+ linked_columns:
31
+ # user_id: "/admin/users/{value}"
32
+
33
+ smart_columns:
34
+ # user_id: "SELECT id, name FROM users WHERE id IN {value}"
35
+
36
+ # create audits
37
+ audit: true
38
+
39
+ # change the time zone
40
+ # time_zone: "Pacific Time (US & Canada)"
41
+
42
+ # class name of the user model
43
+ # user_class: User
44
+
45
+ # method name for the current user
46
+ # user_method: current_user
47
+
48
+ # method name for the display name
49
+ # user_name: name
50
+
51
+ # optional auth method to use as a before_action (default: nil)
52
+ # before_action: :authenticate!
53
+
54
+ # email to send checks from
55
+ # from_email: blazer@example.org
56
+
57
+ # mapbox_access_token: ''
58
+
59
+ check_schedules:
60
+ - "1 day"
61
+ - "1 hour"
62
+ - "5 minutes"
@@ -0,0 +1,45 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :blazer_queries do |t|
4
+ t.references :creator
5
+ t.string :name
6
+ t.text :description
7
+ t.text :statement
8
+ t.string :data_source
9
+ t.timestamps null: false
10
+ end
11
+
12
+ create_table :blazer_audits do |t|
13
+ t.references :user
14
+ t.references :query
15
+ t.text :statement
16
+ t.string :data_source
17
+ t.timestamp :created_at
18
+ end
19
+
20
+ create_table :blazer_dashboards do |t|
21
+ t.references :creator
22
+ t.text :name
23
+ t.timestamps null: false
24
+ end
25
+
26
+ create_table :blazer_dashboard_queries do |t|
27
+ t.references :dashboard
28
+ t.references :query
29
+ t.integer :position
30
+ t.timestamps null: false
31
+ end
32
+
33
+ create_table :blazer_checks do |t|
34
+ t.references :creator
35
+ t.references :query
36
+ t.string :state
37
+ t.string :schedule
38
+ t.text :emails
39
+ t.string :check_type
40
+ t.text :message
41
+ t.timestamp :last_run_at
42
+ t.timestamps null: false
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ namespace :blazer do
2
+ desc "run checks"
3
+ task :run_checks, [:schedule] => :environment do |t, args|
4
+ Blazer.run_checks(schedule: args[:schedule] || ENV["SCHEDULE"])
5
+ end
6
+
7
+ task send_failing_checks: :environment do
8
+ Blazer.send_failing_checks
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sql-jarvis
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.8.0
5
+ platform: ruby
6
+ authors:
7
+ - ThanhKhoaIT
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: chartkick
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: safely_block
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description:
84
+ email:
85
+ - thanhkhoait@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CHANGELOG.md
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - app/assets/fonts/blazer/glyphicons-halflings-regular.eot
97
+ - app/assets/fonts/blazer/glyphicons-halflings-regular.svg
98
+ - app/assets/fonts/blazer/glyphicons-halflings-regular.ttf
99
+ - app/assets/fonts/blazer/glyphicons-halflings-regular.woff
100
+ - app/assets/fonts/blazer/glyphicons-halflings-regular.woff2
101
+ - app/assets/javascripts/blazer/Chart.js
102
+ - app/assets/javascripts/blazer/Sortable.js
103
+ - app/assets/javascripts/blazer/ace.js
104
+ - app/assets/javascripts/blazer/ace/ace.js
105
+ - app/assets/javascripts/blazer/ace/ext-language_tools.js
106
+ - app/assets/javascripts/blazer/ace/mode-sql.js
107
+ - app/assets/javascripts/blazer/ace/snippets/sql.js
108
+ - app/assets/javascripts/blazer/ace/snippets/text.js
109
+ - app/assets/javascripts/blazer/ace/theme-twilight.js
110
+ - app/assets/javascripts/blazer/application.js
111
+ - app/assets/javascripts/blazer/bootstrap.js
112
+ - app/assets/javascripts/blazer/chartkick.js
113
+ - app/assets/javascripts/blazer/daterangepicker.js
114
+ - app/assets/javascripts/blazer/fuzzysearch.js
115
+ - app/assets/javascripts/blazer/highlight.pack.js
116
+ - app/assets/javascripts/blazer/jquery.js
117
+ - app/assets/javascripts/blazer/jquery.stickytableheaders.js
118
+ - app/assets/javascripts/blazer/jquery_ujs.js
119
+ - app/assets/javascripts/blazer/moment-timezone.js
120
+ - app/assets/javascripts/blazer/moment.js
121
+ - app/assets/javascripts/blazer/queries.js
122
+ - app/assets/javascripts/blazer/routes.js
123
+ - app/assets/javascripts/blazer/selectize.js
124
+ - app/assets/javascripts/blazer/stupidtable.js
125
+ - app/assets/javascripts/blazer/vue.js
126
+ - app/assets/stylesheets/blazer/application.css
127
+ - app/assets/stylesheets/blazer/bootstrap.css.erb
128
+ - app/assets/stylesheets/blazer/daterangepicker-bs3.css
129
+ - app/assets/stylesheets/blazer/github.css
130
+ - app/assets/stylesheets/blazer/selectize.default.css
131
+ - app/controllers/blazer/base_controller.rb
132
+ - app/controllers/blazer/checks_controller.rb
133
+ - app/controllers/blazer/dashboards_controller.rb
134
+ - app/controllers/blazer/queries_controller.rb
135
+ - app/helpers/blazer/base_helper.rb
136
+ - app/mailers/blazer/check_mailer.rb
137
+ - app/models/blazer/audit.rb
138
+ - app/models/blazer/check.rb
139
+ - app/models/blazer/connection.rb
140
+ - app/models/blazer/dashboard.rb
141
+ - app/models/blazer/dashboard_query.rb
142
+ - app/models/blazer/query.rb
143
+ - app/models/blazer/record.rb
144
+ - app/views/blazer/_nav.html.erb
145
+ - app/views/blazer/_variables.html.erb
146
+ - app/views/blazer/check_mailer/failing_checks.html.erb
147
+ - app/views/blazer/check_mailer/state_change.html.erb
148
+ - app/views/blazer/checks/_form.html.erb
149
+ - app/views/blazer/checks/edit.html.erb
150
+ - app/views/blazer/checks/index.html.erb
151
+ - app/views/blazer/checks/new.html.erb
152
+ - app/views/blazer/dashboards/_form.html.erb
153
+ - app/views/blazer/dashboards/edit.html.erb
154
+ - app/views/blazer/dashboards/new.html.erb
155
+ - app/views/blazer/dashboards/show.html.erb
156
+ - app/views/blazer/queries/_form.html.erb
157
+ - app/views/blazer/queries/edit.html.erb
158
+ - app/views/blazer/queries/home.html.erb
159
+ - app/views/blazer/queries/new.html.erb
160
+ - app/views/blazer/queries/run.html.erb
161
+ - app/views/blazer/queries/schema.html.erb
162
+ - app/views/blazer/queries/show.html.erb
163
+ - app/views/layouts/blazer/application.html.erb
164
+ - blazer.gemspec
165
+ - config/routes.rb
166
+ - lib/blazer.rb
167
+ - lib/blazer/adapters/athena_adapter.rb
168
+ - lib/blazer/adapters/base_adapter.rb
169
+ - lib/blazer/adapters/bigquery_adapter.rb
170
+ - lib/blazer/adapters/drill_adapter.rb
171
+ - lib/blazer/adapters/elasticsearch_adapter.rb
172
+ - lib/blazer/adapters/mongodb_adapter.rb
173
+ - lib/blazer/adapters/presto_adapter.rb
174
+ - lib/blazer/adapters/sql_adapter.rb
175
+ - lib/blazer/data_source.rb
176
+ - lib/blazer/detect_anomalies.R
177
+ - lib/blazer/engine.rb
178
+ - lib/blazer/result.rb
179
+ - lib/blazer/run_statement.rb
180
+ - lib/blazer/run_statement_job.rb
181
+ - lib/blazer/version.rb
182
+ - lib/generators/blazer/install_generator.rb
183
+ - lib/generators/blazer/templates/config.yml
184
+ - lib/generators/blazer/templates/install.rb
185
+ - lib/tasks/blazer.rake
186
+ homepage: https://github.com/ThanhKhoaIT/blazer
187
+ licenses:
188
+ - MIT
189
+ metadata: {}
190
+ post_install_message:
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 2.6.11
207
+ signing_key:
208
+ specification_version: 4
209
+ summary: Fork from ankane! Explore your data with SQL. Easily create charts and dashboards,
210
+ and share them with your team.
211
+ test_files: []