Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ gem "unpwn", "~> 1.0"
gem "webauthn", "~> 3.4"
gem "browser", "~> 6.2"
gem "bcrypt", "~> 3.1"
gem "blazer", "~> 3.3.0"
gem "maintenance_tasks", "~> 2.12"
gem "strong_migrations", "~> 2.5"
gem "phlex-rails", "~> 2.3"
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ GEM
bigdecimal (3.3.1)
bindata (2.5.1)
bitarray (1.3.1)
blazer (3.3.0)
activerecord (>= 7.1)
chartkick (>= 5)
csv
railties (>= 7.1)
safely_block (>= 0.4)
bloomer (1.0.0)
bitarray
msgpack
Expand Down Expand Up @@ -777,6 +783,7 @@ GEM
ruby-statistics (4.0.1)
ruby2_keywords (0.0.5)
rubyzip (3.2.1)
safely_block (0.5.0)
safety_net_attestation (0.5.0)
jwt (>= 2.0, < 4.0)
sanitize (7.0.0)
Expand Down Expand Up @@ -926,6 +933,7 @@ DEPENDENCIES
aws-sdk-sqs (~> 1.104)
bcrypt (~> 3.1)
better_html (~> 2.2)
blazer (~> 3.3.0)
bootsnap (~> 1.18)
brakeman (~> 7.1)
browser (~> 6.2)
Expand Down Expand Up @@ -1082,6 +1090,7 @@ CHECKSUMS
bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
bindata (2.5.1) sha256=53186a1ec2da943d4cb413583d680644eb810aacbf8902497aac8f191fad9e58
bitarray (1.3.1) sha256=6ec714933c4a6100b31dcb49a68135a0409524a1834c9d614b0bd929e3da0743
blazer (3.3.0) sha256=01e151091ce1e7d27c156243916b2f13109ef2ef1a16cfa62bef67f4c5fd169f
bloomer (1.0.0) sha256=57a0d3a78628db9a92c6723f06c67697e420abcdb05aa757c6dfae607251d272
bootsnap (1.18.6) sha256=0ae2393c1e911e38be0f24e9173e7be570c3650128251bf06240046f84a07d00
brakeman (7.1.0) sha256=bbc708a75a53008490c8b9600b97fa85cb3d5a8818dd1560f18e0b89475d48af
Expand Down Expand Up @@ -1325,6 +1334,7 @@ CHECKSUMS
ruby-statistics (4.0.1) sha256=aede68e6261b979431b31ba39aa661844c18f97a89966768cb60edf2a56b6782
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
rubyzip (3.2.1) sha256=a8e57709e47a36ba3d71921e9c636c711fff91b16c52adba8c1d6cac94ea512d
safely_block (0.5.0) sha256=782c342bc400a79c1233c40cf8c379da6116c6cfd1d7c1f17f0ef2ef11090103
safety_net_attestation (0.5.0) sha256=c8cd01dd550dbe8553862918af6355a04672db11d218ec96104ce3955293f2aa
sanitize (7.0.0) sha256=269d1b9d7326e69307723af5643ec032ff86ad616e72a3b36d301ac75a273984
sawyer (0.9.2) sha256=fa3a72d62a4525517b18857ddb78926aab3424de0129be6772a8e2ba240e7aca
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:
url: <%= ENV["DATABASE_URL"] %>

# statement timeout, in seconds
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

override_csp: true

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

# class name of the user model
user_class: Admin::GitHubUser

# method name for the current user
user_method: admin_user

# method name for the display name
user_name: login

# 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
3 changes: 2 additions & 1 deletion config/initializers/better_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config.template_exclusion_filter = proc { |filename|
filename.include?("avo") ||
filename.include?("/railties-") ||
filename.include?("lookbook-")
filename.include?("lookbook-") ||
filename.include?("blazer")
}
end
3 changes: 3 additions & 0 deletions config/initializers/blazer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.autoloaders.main.on_load("Blazer::BaseController") do
Blazer::BaseController.include GitHubOAuthable
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@
mount MaintenanceTasks::Engine, at: "maintenance_tasks"
mount PgHero::Engine, at: "pghero"
mount Flipper::UI.app(Flipper), at: '/features'
mount Blazer::Engine, at: "blazer"
end

mount_avo
Expand Down
47 changes: 47 additions & 0 deletions db/migrate/20251106032329_install_blazer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class InstallBlazer < ActiveRecord::Migration[8.0]
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[8.0].define(version: 2025_08_05_054836) do
ActiveRecord::Schema[8.0].define(version: 2025_11_06_032329) do
# These are extensions that must be enabled in order to support this database
enable_extension "hstore"
enable_extension "pg_catalog.plpgsql"
Expand Down Expand Up @@ -78,6 +78,62 @@
t.index ["auditable_type", "auditable_id"], name: "index_audits_on_auditable"
end

create_table "blazer_audits", force: :cascade do |t|
t.bigint "user_id"
t.bigint "query_id"
t.text "statement"
t.string "data_source"
t.datetime "created_at"
t.index ["query_id"], name: "index_blazer_audits_on_query_id"
t.index ["user_id"], name: "index_blazer_audits_on_user_id"
end

create_table "blazer_checks", force: :cascade do |t|
t.bigint "creator_id"
t.bigint "query_id"
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.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_blazer_checks_on_creator_id"
t.index ["query_id"], name: "index_blazer_checks_on_query_id"
end

create_table "blazer_dashboard_queries", force: :cascade do |t|
t.bigint "dashboard_id"
t.bigint "query_id"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["dashboard_id"], name: "index_blazer_dashboard_queries_on_dashboard_id"
t.index ["query_id"], name: "index_blazer_dashboard_queries_on_query_id"
end

create_table "blazer_dashboards", force: :cascade do |t|
t.bigint "creator_id"
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_blazer_dashboards_on_creator_id"
end

create_table "blazer_queries", force: :cascade do |t|
t.bigint "creator_id"
t.string "name"
t.text "description"
t.text "statement"
t.string "data_source"
t.string "status"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_blazer_queries_on_creator_id"
end

create_table "deletions", id: :serial, force: :cascade do |t|
t.integer "user_id"
t.string "rubygem"
Expand Down
Loading