Skip to content

Commit

Permalink
add blazer bi
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed Jan 22, 2024
1 parent 87ec4cf commit b19feb1
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ gem "sitepress-rails", "~> 4.0"
gem "markdown-rails", "~> 2.1"
gem "rouge", "~> 4.2"

# analytics
gem "ahoy_matey"
gem "blazer"
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ GEM
bindex (0.8.1)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
blazer (3.0.3)
activerecord (>= 6.1)
chartkick (>= 5)
csv
railties (>= 6.1)
safely_block (>= 0.4)
bootsnap (1.17.1)
msgpack (~> 1.2)
builder (3.2.4)
Expand All @@ -144,12 +150,14 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chartkick (5.0.5)
coderay (1.1.3)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
cssbundling-rails (1.3.3)
railties (>= 6.0.0)
csv (3.2.8)
date (3.3.4)
debug (1.9.1)
irb (~> 1.10)
Expand Down Expand Up @@ -530,6 +538,7 @@ DEPENDENCIES
authentication-zero (~> 3.0)
avo (>= 3.2)
bcrypt (~> 3.1.7)
blazer
bootsnap
byebug
capybara
Expand Down
80 changes: 80 additions & 0 deletions config/blazer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# see https://github.com/ankane/blazer for more info

data_sources:
main:
development:
url: sqlite3:storage/development.sqlite3
production:
url: sqlite3:storage/production.sqlite3
# statement timeout, in seconds
# none by default
# timeout: 15

# caching settings
# can greatly improve speed
# off by default
# cache:
# mode: slow # or all
# expires_in: 60 # min
# slow_threshold: 15 # sec, only used in slow mode

# wrap queries in a transaction for safety
# not necessary if you use a read-only user
# true by default
# use_transaction: false

smart_variables:
# zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
# period: ["day", "week", "month"]
# status: {0: "Active", 1: "Archived"}

linked_columns:
# user_id: "/admin/users/{value}"

smart_columns:
# user_id: "SELECT id, name FROM users WHERE id IN {value}"

# create audits
audit: true

# change the time zone
# time_zone: "Pacific Time (US & Canada)"

# class name of the user model
# user_class: User

# method name for the current user
# user_method: current_user

# method name for the display name
# user_name: name

# custom before_action to use for auth
# before_action_method: require_admin

# email to send checks from
# from_email: [email protected]

# webhook for Slack
# slack_webhook_url: <%= ENV["BLAZER_SLACK_WEBHOOK_URL"] %>

check_schedules:
- "1 day"
- "1 hour"
- "5 minutes"
# enable anomaly detection
# note: with trend, time series are sent to https://trendapi.org
# anomaly_checks: prophet / trend / anomaly_detection

# enable forecasting
# note: with trend, time series are sent to https://trendapi.org
# forecasting: prophet / trend

# enable map
# mapbox_access_token: <%= ENV["MAPBOX_ACCESS_TOKEN"] %>

# enable uploads
# uploads:
# url: <%= ENV["BLAZER_UPLOADS_URL"] %>
# schema: uploads
# data_source: main
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

authenticate :admin do
mount Avo::Engine, at: Avo.configuration.root_path
mount Blazer::Engine, at: "blazer"
end

# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
Expand Down
47 changes: 47 additions & 0 deletions db/migrate/20240122061850_install_blazer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class InstallBlazer < ActiveRecord::Migration[7.1]
def change
create_table :blazer_queries do |t|
t.references :creator
t.string :name
t.text :description
t.text :statement
t.string :data_source
t.string :status
t.timestamps null: false
end

create_table :blazer_audits do |t|
t.references :user
t.references :query
t.text :statement
t.string :data_source
t.datetime :created_at
end

create_table :blazer_dashboards do |t|
t.references :creator
t.string :name
t.timestamps null: false
end

create_table :blazer_dashboard_queries do |t|
t.references :dashboard
t.references :query
t.integer :position
t.timestamps null: false
end

create_table :blazer_checks do |t|
t.references :creator
t.references :query
t.string :state
t.string :schedule
t.text :emails
t.text :slack_channels
t.string :check_type
t.text :message
t.datetime :last_run_at
t.timestamps null: false
end
end
end
58 changes: 57 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b19feb1

Please sign in to comment.