bnb_blazer 0.2.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.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/.docker-development-vars +1 -0
  3. data/.gitignore +31 -0
  4. data/.rspec +3 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +6 -0
  7. data/Gemfile +54 -0
  8. data/Gemfile.lock +233 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +35 -0
  11. data/Rakefile +7 -0
  12. data/app/assets/config/manifest.js +3 -0
  13. data/app/assets/images/.keep +0 -0
  14. data/app/assets/images/bnb_intel_logo.png +0 -0
  15. data/app/assets/stylesheets/application.css +83 -0
  16. data/app/channels/application_cable/channel.rb +4 -0
  17. data/app/channels/application_cable/connection.rb +4 -0
  18. data/app/controllers/application_controller.rb +2 -0
  19. data/app/controllers/concerns/.keep +0 -0
  20. data/app/helpers/application_helper.rb +2 -0
  21. data/app/jobs/application_job.rb +2 -0
  22. data/app/mailers/application_mailer.rb +4 -0
  23. data/app/models/application_record.rb +3 -0
  24. data/app/models/concerns/.keep +0 -0
  25. data/app/models/user.rb +2 -0
  26. data/app/views/blazer/_variables.html.haml +104 -0
  27. data/app/views/blazer/checks/_form.html.haml +51 -0
  28. data/app/views/blazer/checks/edit.html.haml +2 -0
  29. data/app/views/blazer/checks/index.html.haml +50 -0
  30. data/app/views/blazer/checks/new.html.haml +2 -0
  31. data/app/views/blazer/dashboards/_form.html.haml +64 -0
  32. data/app/views/blazer/dashboards/edit.html.haml +2 -0
  33. data/app/views/blazer/dashboards/new.html.haml +2 -0
  34. data/app/views/blazer/dashboards/show.html.haml +30 -0
  35. data/app/views/blazer/queries/_form.html.haml +226 -0
  36. data/app/views/blazer/queries/edit.html.haml +2 -0
  37. data/app/views/blazer/queries/home.html.haml +142 -0
  38. data/app/views/blazer/queries/new.html.haml +2 -0
  39. data/app/views/blazer/queries/run.html.haml +152 -0
  40. data/app/views/blazer/queries/show.html.haml +45 -0
  41. data/app/views/layouts/blazer/_footer.html.haml +2 -0
  42. data/app/views/layouts/blazer/_navbar.html.haml +25 -0
  43. data/app/views/layouts/blazer/application.html.haml +21 -0
  44. data/bin/bundle +3 -0
  45. data/bin/console +14 -0
  46. data/bin/rails +9 -0
  47. data/bin/rake +9 -0
  48. data/bin/setup +36 -0
  49. data/bin/spring +17 -0
  50. data/bin/update +31 -0
  51. data/bin/yarn +11 -0
  52. data/bnb_blazer.gemspec +28 -0
  53. data/config/application.rb +19 -0
  54. data/config/blazer.yml +79 -0
  55. data/config/boot.rb +4 -0
  56. data/config/cable.yml +10 -0
  57. data/config/credentials.yml.enc +1 -0
  58. data/config/database.yml +19 -0
  59. data/config/environment.rb +5 -0
  60. data/config/environments/development.rb +61 -0
  61. data/config/environments/production.rb +94 -0
  62. data/config/environments/test.rb +46 -0
  63. data/config/initializers/application_controller_renderer.rb +8 -0
  64. data/config/initializers/assets.rb +14 -0
  65. data/config/initializers/backtrace_silencers.rb +7 -0
  66. data/config/initializers/content_security_policy.rb +25 -0
  67. data/config/initializers/cookies_serializer.rb +5 -0
  68. data/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/config/initializers/inflections.rb +16 -0
  70. data/config/initializers/mime_types.rb +4 -0
  71. data/config/initializers/wrap_parameters.rb +14 -0
  72. data/config/locales/en.yml +33 -0
  73. data/config/puma.rb +37 -0
  74. data/config/routes.rb +3 -0
  75. data/config/spring.rb +6 -0
  76. data/config/storage.yml +34 -0
  77. data/config.ru +5 -0
  78. data/db/migrate/20210309231658_install_blazer.rb +47 -0
  79. data/db/migrate/20210309231908_create_users.rb +13 -0
  80. data/db/schema.rb +85 -0
  81. data/db/seeds.rb +45 -0
  82. data/docker-compose.yml +22 -0
  83. data/lib/assets/.keep +0 -0
  84. data/lib/bnb_blazer/bnb_blazer.rb +6 -0
  85. data/lib/bnb_blazer/version.rb +3 -0
  86. data/lib/tasks/.keep +0 -0
  87. data/log/.keep +0 -0
  88. data/package.json +5 -0
  89. data/public/404.html +67 -0
  90. data/public/422.html +67 -0
  91. data/public/500.html +66 -0
  92. data/public/apple-touch-icon-precomposed.png +0 -0
  93. data/public/apple-touch-icon.png +0 -0
  94. data/public/favicon.ico +0 -0
  95. data/public/robots.txt +1 -0
  96. data/tmp/.keep +0 -0
  97. data/vendor/.keep +0 -0
  98. metadata +156 -0
@@ -0,0 +1,152 @@
1
+ - if @error
2
+ .alert.alert-danger= @error.first(200)
3
+ - elsif !@success
4
+ - if @only_chart
5
+ %p.text-muted Select variables
6
+ - else
7
+ .alert.alert-info Can’t preview queries with variables...yet!
8
+ - elsif @cohort_analysis
9
+ - if @cohort_error
10
+ .alert.alert-info= @cohort_error
11
+ - else
12
+ = render partial: "cohorts"
13
+ - else
14
+ - unless @only_chart
15
+ = render partial: "caching"
16
+ %p.text-muted{:style => "margin-bottom: 10px;"}
17
+ - if @row_limit && @rows.size > @row_limit
18
+ First
19
+ - @rows = @rows.first(@row_limit)
20
+ = pluralize(@rows.size, "row")
21
+ - @checks.select(&:state).each do |check|
22
+ ·
23
+ %small{:class => "check-state #{check.state.parameterize.gsub("-", "_")}"}= link_to check.state.upcase, edit_check_path(check)
24
+ - if check.try(:message)
25
+ · #{check.message}
26
+ - if @query && @result.forecastable? && !params[:forecast]
27
+ ·
28
+ \#{link_to "Forecast", query_path(@query, {forecast: "t"}.merge(variable_params(@query)))}
29
+ - if @forecast_error
30
+ .alert.alert-danger= @forecast_error
31
+ - if @cohort_error
32
+ .alert.alert-info= @cohort_error
33
+ - if @rows.any?
34
+ - values = @rows.first
35
+ - chart_id = SecureRandom.hex
36
+ - column_types = @result.column_types
37
+ - chart_type = @result.chart_type
38
+ - chart_options = {id: chart_id}
39
+ - if ["line", "line2"].include?(chart_type)
40
+ - chart_options.merge!(min: nil)
41
+ - if chart_type == "scatter"
42
+ - chart_options.merge!(library: {tooltips: {intersect: false}})
43
+ - elsif ["bar", "bar2"].include?(chart_type)
44
+ - chart_options.merge!(library: {tooltips: {intersect: false, axis: 'x'}})
45
+ - elsif chart_type != "pie"
46
+ - if column_types.size == 2 || @forecast
47
+ - chart_options.merge!(library: {tooltips: {intersect: false, axis: 'x'}})
48
+ - else
49
+ - chart_options.merge!(library: {tooltips: {intersect: false}})
50
+ - series_library = {}
51
+ - target_index = @columns.index { |k| k.downcase == "target" }
52
+ - if target_index
53
+ - color = "#109618"
54
+ - series_library[target_index - 1] = {pointStyle: "line", hitRadius: 5, borderColor: color, pointBackgroundColor: color, backgroundColor: color, pointHoverBackgroundColor: color}
55
+ - if @forecast
56
+ - color = "#54a3ee"
57
+ - series_library[1] = {borderDash: [8], borderColor: color, pointBackgroundColor: color, backgroundColor: color, pointHoverBackgroundColor: color}
58
+ - if blazer_maps? && @markers.any?
59
+ #map{:style => "height: #{@only_chart ? 300 : 500}px;"}
60
+ :javascript
61
+ #{blazer_js_var "mapboxAccessToken", Blazer.mapbox_access_token}
62
+ #{blazer_js_var "markers", @markers}
63
+ L.mapbox.accessToken = mapboxAccessToken;
64
+ var map = L.mapbox.map('map')
65
+ .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));
66
+ var featureLayer = L.mapbox.featureLayer().addTo(map);
67
+ var geojson = [];
68
+ for (var i = 0; i < markers.length; i++) {
69
+ var marker = markers[i];
70
+ geojson.push({
71
+ type: 'Feature',
72
+ geometry: {
73
+ type: 'Point',
74
+ coordinates: [
75
+ marker.longitude,
76
+ marker.latitude
77
+ ]
78
+ },
79
+ properties: {
80
+ description: marker.title,
81
+ 'marker-color': '#f86767',
82
+ 'marker-size': 'medium'
83
+ }
84
+ });
85
+ }
86
+ featureLayer.setGeoJSON(geojson);
87
+ map.fitBounds(featureLayer.getBounds());
88
+ - elsif chart_type == "line"
89
+ - chart_data = @columns[1..-1].each_with_index.map{ |k, i| {name: blazer_series_name(k), data: @rows.map{ |r| [r[0], r[i + 1]] }, library: series_library[i]} }
90
+ = line_chart chart_data, **chart_options
91
+ - elsif chart_type == "line2"
92
+ = line_chart @rows.group_by { |r| v = r[1]; (@boom[@columns[1]] || {})[v.to_s] || v }.each_with_index.map { |(name, v), i| {name: blazer_series_name(name), data: v.map { |v2| [v2[0], v2[2]] }, library: series_library[i]} }, **chart_options
93
+ - elsif chart_type == "pie"
94
+ = pie_chart @rows.map { |r| [(@boom[@columns[0]] || {})[r[0].to_s] || r[0], r[1]] }, **chart_options
95
+ - elsif chart_type == "bar"
96
+ = column_chart (values.size - 1).times.map { |i| name = @columns[i + 1]; {name: blazer_series_name(name), data: @rows.first(20).map { |r| [(@boom[@columns[0]] || {})[r[0].to_s] || r[0], r[i + 1]] } } }, **chart_options
97
+ - elsif chart_type == "bar2"
98
+ - first_20 = @rows.group_by { |r| r[0] }.values.first(20).flatten(1)
99
+ - labels = first_20.map { |r| r[0] }.uniq
100
+ - series = first_20.map { |r| r[1] }.uniq
101
+ - labels.each do |l|
102
+ - series.each do |s|
103
+ - first_20 << [l, s, 0] unless first_20.find { |r| r[0] == l && r[1] == s }
104
+ = column_chart first_20.group_by { |r| v = r[1]; (@boom[@columns[1]] || {})[v.to_s] || v }.each_with_index.map { |(name, v), i| {name: blazer_series_name(name), data: v.sort_by { |r2| labels.index(r2[0]) }.map { |v2| v3 = v2[0]; [(@boom[@columns[0]] || {})[v3.to_s] || v3, v2[2]] }} }, **chart_options
105
+ - elsif chart_type == "scatter"
106
+ = scatter_chart @rows, xtitle: @columns[0], ytitle: @columns[1], **chart_options
107
+ - elsif @only_chart
108
+ - if @rows.size == 1 && @rows.first.size == 1
109
+ - v = @rows.first.first
110
+ - if v.is_a?(String) && v == ""
111
+ .text-muted empty string
112
+ - else
113
+ %p{:style => "font-size: 160px;"}= blazer_format_value(@columns.first, v)
114
+ - else
115
+ - @no_chart = true
116
+ - unless @only_chart && !@no_chart
117
+ - header_width = 100 / @columns.size.to_f
118
+ .results-container
119
+ - if @columns == ["QUERY PLAN"]
120
+ %pre
121
+ %code= @rows.map { |r| r[0] }.join("\n")
122
+ - elsif @columns == ["PLAN"] && @data_source.adapter == "druid"
123
+ %pre
124
+ %code= @rows[0][0]
125
+ - else
126
+ %table.table.results-table
127
+ %thead
128
+ %tr
129
+ - @columns.each_with_index do |key, i|
130
+ - type = @column_types[i]
131
+ %th{"data-sort" => type, :style => "width: #{header_width}%;"}
132
+ %div{:style => "min-width: #{@min_width_types.include?(i) ? 180 : 60}px;"}
133
+ = key
134
+ %tbody
135
+ - @rows.each do |row|
136
+ %tr
137
+ - row.each_with_index do |v, i|
138
+ - k = @columns[i]
139
+ %td
140
+ - if v.is_a?(Time)
141
+ - v = blazer_time_value(@data_source, k, v)
142
+ - unless v.nil?
143
+ - if v.is_a?(String) && v == ""
144
+ .text-muted empty string
145
+ - elsif @linked_columns[k]
146
+ = link_to blazer_format_value(k, v), @linked_columns[k].gsub("{value}", u(v.to_s)), target: "_blank"
147
+ - else
148
+ = blazer_format_value(k, v)
149
+ - if v2 = (@boom[k] || {})[v.nil? ? v : v.to_s]
150
+ .text-muted= v2
151
+ - elsif @only_chart
152
+ %p.text-muted No rows
@@ -0,0 +1,45 @@
1
+ - blazer_title @query.name
2
+ %nav.navbar.navbar-default.navbar-fixed-top
3
+ .container
4
+ = render layout: "layouts/blazer/navbar" do
5
+ %li= link_to "Edit", edit_query_path(@query, variable_params(@query)), class: "text-muted font-weight-bold px-1", disabled: !@query.editable?(blazer_user)
6
+ %li= link_to "Fork", new_query_path(variable_params(@query).merge(fork_query_id: @query.id, data_source: @query.data_source, name: @query.name)), class: "text-muted font-weight-bold px-1"
7
+ - if !@error && @success
8
+ %li= link_to "Download", run_queries_path(query_id: @query.id, format: "csv", forecast: params[:forecast], cohort_period: params[:cohort_period]), params: {statement: @statement}, class: "text-muted font-weight-bold px-1"
9
+
10
+ #blazer-content
11
+ %div{:style => "margin-bottom: 70px;"}
12
+ - if @sql_errors.any?
13
+ .alert.alert-danger
14
+ %ul
15
+ - @sql_errors.each do |message|
16
+ %li= message
17
+ %h3.text-center=@query.name
18
+ - if @query.description.present?
19
+ %p= @query.description
20
+ = render partial: "blazer/variables", locals: {action: query_path(@query)}
21
+ %pre#code
22
+ %code= @statement
23
+ - if @success
24
+ #results
25
+ %p.text-muted.text-uppercase Loading...
26
+ :javascript
27
+ function showRun(data) {
28
+ $("#results").html(data)
29
+ $("#results table").stupidtable(stupidtableCustomSettings).stickyTableHeaders({fixedOffset: 60})
30
+ }
31
+
32
+ function showError(message) {
33
+ $("#results").addClass("query-error").html(message)
34
+ }
35
+
36
+ #{blazer_js_var "data", variable_params(@query).merge(statement: @statement, query_id: @query.id, data_source: @query.data_source)}
37
+
38
+ runQuery(data, showRun, showError)
39
+ - unless %w(mongodb).include?(Blazer.data_sources[@query.data_source].adapter)
40
+ :javascript
41
+ // do not highlight really long queries
42
+ // this can lead to performance issues
43
+ if ($("code").text().length < 10000) {
44
+ hljs.highlightBlock(document.getElementById("code"));
45
+ }
@@ -0,0 +1,2 @@
1
+ #footer
2
+ =image_tag "bnb_intel_logo.png", style: "margin: auto; display: block"
@@ -0,0 +1,25 @@
1
+ .navbar-header
2
+ %button.navbar-toggle.collapsed{"aria-expanded" => "false", "data-target" => "#navbar-collapse", "data-toggle" => "collapse", :type => "button"}
3
+ %span.sr-only Toggle navigation
4
+ %span.icon-bar
5
+ %span.icon-bar
6
+ %span.icon-bar
7
+ = image_tag "bnb_intel_logo.png", class: "img-responsive"
8
+ #navbar-collapse.collapse.navbar-collapse
9
+ %ul.nav.navbar-nav
10
+ .btn-group
11
+ = link_to "Home", root_path, class: "btn btn-default", data: { type: "button" }
12
+ %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
13
+ %span.caret
14
+ %span.sr-only Toggle Dropdown
15
+ %ul.dropdown-menu
16
+ %li= link_to "Checks", checks_path
17
+ - if Blazer.uploads?
18
+ %li= link_to "Uploads", uploads_path
19
+ %li.divider{role: "separator"}
20
+ %li= link_to "New Query", new_query_path
21
+ %li= link_to "New Dashboard", new_dashboard_path
22
+ - check_params = @query ? {query_id: @query.id} : {}
23
+ %li= link_to "New Check", new_check_path(check_params)
24
+ %ul.nav.navbar-nav.navbar-right
25
+ = yield
@@ -0,0 +1,21 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{ content: "width=device-width, initial-scale=1.0", name:"viewport" }
5
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
6
+ %title= blazer_title ? blazer_title : "Blazer"
7
+ %meta{:charset => "utf-8"}/
8
+ = favicon_link_tag "blazer/favicon.png"
9
+ = stylesheet_link_tag "blazer/application"
10
+ = stylesheet_link_tag "application"
11
+ = javascript_include_tag "blazer/application"
12
+ :javascript
13
+ #{blazer_js_var "rootPath", root_path}
14
+ - if blazer_maps?
15
+ = stylesheet_link_tag "https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css", integrity: "sha384-vxzdEt+wZRPNQbhChjmiaFMLWg86IGuq1NGDehJHsD2mphYkxXll/eSs16WWi6Dq", crossorigin: "anonymous"
16
+ = javascript_include_tag "https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js", integrity: "sha384-CTBEiDLiZJ8gkAQ3fYGoeiRp81/ecNiBkGz11jXFALOZ6++rbnqmdo6OImkmr1MO", crossorigin: "anonymous"
17
+ = csrf_meta_tags
18
+ %body
19
+ .container.blazer-content
20
+ = yield
21
+ = render "layouts/blazer/footer"
data/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bnb_blazer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rails ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../config/application', __dir__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
data/bin/rake ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
data/bin/setup ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a starting point to setup your application.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
data/bin/spring ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads Spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
12
+ if spring
13
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14
+ gem 'spring', spring.version
15
+ require 'spring/binstub'
16
+ end
17
+ end
data/bin/update ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
4
+
5
+ # path to your application root.
6
+ APP_ROOT = File.expand_path('..', __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args) || abort("\n== Command #{args} failed ==")
10
+ end
11
+
12
+ chdir APP_ROOT do
13
+ # This script is a way to update your development environment automatically.
14
+ # Add necessary update steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
data/bin/yarn ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ begin
5
+ exec "yarnpkg", *ARGV
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'lib/bnb_blazer/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "bnb_blazer"
5
+ spec.version = BnbBlazer::VERSION
6
+ spec.authors = ["Joe"]
7
+ spec.email = ["pickertjoe@gmail.com"]
8
+
9
+ spec.summary = "Customized branding of the Blazer gem for BNB projects"
10
+ spec.description = "Customized branding of the Blazer gem for BNB projects"
11
+ spec.homepage = "https://github.com/brandnewbox/bnb_blazer"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/brandnewbox/bnb_blazer"
17
+
18
+ spec.add_dependency "blazer", "~> 2.4"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module BnbBlazer
10
+ class Application < Rails::Application
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 5.2
13
+
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration can go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded after loading
17
+ # the framework and any gems in your application.
18
+ end
19
+ end
data/config/blazer.yml ADDED
@@ -0,0 +1,79 @@
1
+ # see https://github.com/ankane/blazer for more info
2
+
3
+ data_sources:
4
+ main:
5
+ url: <%= ENV["BLAZER_DATABASE_URL"] %>
6
+
7
+ # statement timeout, in seconds
8
+ # none by default
9
+ # timeout: 15
10
+
11
+ # caching settings
12
+ # can greatly improve speed
13
+ # off by default
14
+ # cache:
15
+ # mode: slow # or all
16
+ # expires_in: 60 # min
17
+ # slow_threshold: 15 # sec, only used in slow mode
18
+
19
+ # wrap queries in a transaction for safety
20
+ # not necessary if you use a read-only user
21
+ # true by default
22
+ # use_transaction: false
23
+
24
+ smart_variables:
25
+ # zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
26
+ # period: ["day", "week", "month"]
27
+ # status: {0: "Active", 1: "Archived"}
28
+
29
+ linked_columns:
30
+ # user_id: "/admin/users/{value}"
31
+
32
+ smart_columns:
33
+ # user_id: "SELECT id, name FROM users WHERE id IN {value}"
34
+
35
+ # create audits
36
+ audit: true
37
+
38
+ # change the time zone
39
+ # time_zone: "Pacific Time (US & Canada)"
40
+
41
+ # class name of the user model
42
+ # user_class: User
43
+
44
+ # method name for the current user
45
+ # user_method: current_user
46
+
47
+ # method name for the display name
48
+ # user_name: name
49
+
50
+ # custom before_action to use for auth
51
+ # before_action_method: require_admin
52
+
53
+ # email to send checks from
54
+ # from_email: blazer@example.org
55
+
56
+ # webhook for Slack
57
+ # slack_webhook_url: <%= ENV["BLAZER_SLACK_WEBHOOK_URL"] %>
58
+
59
+ check_schedules:
60
+ - "1 day"
61
+ - "1 hour"
62
+ - "5 minutes"
63
+
64
+ # enable anomaly detection
65
+ # note: with trend, time series are sent to https://trendapi.org
66
+ # anomaly_checks: trend / r
67
+
68
+ # enable forecasting
69
+ # note: with trend, time series are sent to https://trendapi.org
70
+ # forecasting: trend / prophet
71
+
72
+ # enable map
73
+ # mapbox_access_token: <%= ENV["MAPBOX_ACCESS_TOKEN"] %>
74
+
75
+ # enable uploads
76
+ # uploads:
77
+ # url: <%= ENV["BLAZER_UPLOADS_URL"] %>
78
+ # schema: uploads
79
+ # data_source: main
data/config/boot.rb ADDED
@@ -0,0 +1,4 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
4
+ require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
data/config/cable.yml ADDED
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: bnb_blazer_production
@@ -0,0 +1 @@
1
+ ra2o7cXDbj47EzeLR0L9mMw4Ufh4P0TNYPV6sVapflfdG7LKi0NfgXYO6ibGw1uj3NK7YW3bUzSXSF/Ic5Lbcp3USlvBBDZDOlYX54K3Us1jIueNzL+xpFx5vghr0XY7oh9JQEAu4DEdYMI54XwZJq0kZwOCSgZEeK8NWI4iap8My9iDT5AXy7CN4Sd8aA+cvWiCaNNJ0lCrBbn5RXYL0aCSVn/KVhRl3X5X/TO9IywMbIqdAmaY3isNAbw5SVScmMfYfhqazbQ+afFCrZ6w8mfGTvYJHyKLDLfKf1YAuJUZHRqylSphRWK3N6FyxahDnr4v5HNCr/C0CTIo5GBCDHQneYOHMAVxyikTwNWmVLp0R8PEzgp4Lrs/sCE85hQ90RL86geEg4bttHld7j1pRZvfGWIsQnYKrPCc--lgUHcVJTdYiLftQd--pB/oDByF7wTRR6Zn1wKDzw==
@@ -0,0 +1,19 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: 5
5
+
6
+ development:
7
+ <<: *default
8
+ database: bnb_blazer_development
9
+
10
+ # Warning: The database defined as "test" will be erased and
11
+ # re-generated from your development database when you run "rake".
12
+ # Do not set this db to the same as development or production.
13
+ test:
14
+ <<: *default
15
+ database: bnb_blazer_test
16
+
17
+ production:
18
+ <<: *default
19
+ database: bnb_blazer
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,61 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ # Run rails dev:cache to toggle caching.
17
+ if Rails.root.join('tmp', 'caching-dev.txt').exist?
18
+ config.action_controller.perform_caching = true
19
+
20
+ config.cache_store = :memory_store
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
23
+ }
24
+ else
25
+ config.action_controller.perform_caching = false
26
+
27
+ config.cache_store = :null_store
28
+ end
29
+
30
+ # Store uploaded files on the local file system (see config/storage.yml for options)
31
+ config.active_storage.service = :local
32
+
33
+ # Don't care if the mailer can't send.
34
+ config.action_mailer.raise_delivery_errors = false
35
+
36
+ config.action_mailer.perform_caching = false
37
+
38
+ # Print deprecation notices to the Rails logger.
39
+ config.active_support.deprecation = :log
40
+
41
+ # Raise an error on page load if there are pending migrations.
42
+ config.active_record.migration_error = :page_load
43
+
44
+ # Highlight code that triggered database queries in logs.
45
+ config.active_record.verbose_query_logs = true
46
+
47
+ # Debug mode disables concatenation and preprocessing of assets.
48
+ # This option may cause significant delays in view rendering with a large
49
+ # number of complex assets.
50
+ config.assets.debug = true
51
+
52
+ # Suppress logger output for asset requests.
53
+ config.assets.quiet = true
54
+
55
+ # Raises error for missing translations
56
+ # config.action_view.raise_on_missing_translations = true
57
+
58
+ # Use an evented file watcher to asynchronously detect changes in source code,
59
+ # routes, locales, etc. This feature depends on the listen gem.
60
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
61
+ end