-
Notifications
You must be signed in to change notification settings - Fork 21
Add Blazer gem for business intelligence queries #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f612c9b
Initial plan
Copilot ff7dfd0
Add Blazer gem and install configuration
Copilot 2464338
Add Blazer authentication and foreign key constraints
Copilot bed3a45
Explicitly call require_blazer_access before_action
Copilot fe24632
Improve migration consistency and audit timestamp
Copilot 542f1c4
Add blazer gem for sql quering
maebeale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # see https://github.com/ankane/blazer for more info | ||
|
|
||
| data_sources: | ||
| main: | ||
| url: <%= ENV["BLAZER_DATABASE_URL"].presence || ENV["DATABASE_URL"].presence || "trilogy://root@127.0.0.1/awbw_development" %> | ||
|
|
||
| # 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: email | ||
|
|
||
| # custom before_action to use for auth | ||
| # auth handled via Devise route constraint in routes.rb | ||
|
|
||
| # email to send checks from | ||
| # from_email: blazer@example.org | ||
|
|
||
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Blazer authentication configuration | ||
| # Only allow super_users to access Blazer | ||
| Rails.application.config.to_prepare do | ||
| Blazer::BaseController.class_eval do | ||
| before_action :authenticate_user! | ||
| before_action :require_blazer_access | ||
|
|
||
| private | ||
|
|
||
| def require_blazer_access | ||
| redirect_to root_path, alert: "You are not authorized to access this page." unless current_user&.super_user? | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| class InstallBlazer < ActiveRecord::Migration[8.1] | ||
| def change | ||
| create_table :blazer_queries do |t| | ||
| t.references :creator, type: :integer, foreign_key: { to_table: :users } | ||
| 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, type: :integer, foreign_key: { to_table: :users } | ||
| t.references :query, foreign_key: { to_table: :blazer_queries } | ||
| t.text :statement | ||
| t.string :data_source | ||
| t.timestamp :created_at, null: false | ||
| end | ||
|
|
||
| create_table :blazer_dashboards do |t| | ||
| t.references :creator, type: :integer, foreign_key: { to_table: :users } | ||
| t.string :name | ||
| t.timestamps null: false | ||
| end | ||
|
|
||
| create_table :blazer_dashboard_queries do |t| | ||
| t.references :dashboard, foreign_key: { to_table: :blazer_dashboards } | ||
| t.references :query, foreign_key: { to_table: :blazer_queries } | ||
| t.integer :position | ||
| t.timestamps null: false | ||
| end | ||
|
|
||
| create_table :blazer_checks do |t| | ||
| t.references :creator, type: :integer, foreign_key: { to_table: :users } | ||
| t.references :query, foreign_key: { to_table: :blazer_queries } | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nest the blazer route under call to super_user