|
9 年之前 | |
---|---|---|
app | 9 年之前 | |
config | 9 年之前 | |
lib | 9 年之前 | |
.gitignore | 10 年之前 | |
CHANGELOG.md | 9 年之前 | |
Gemfile | 10 年之前 | |
LICENSE.txt | 10 年之前 | |
README.md | 9 年之前 | |
Rakefile | 10 年之前 | |
blazer.gemspec | 10 年之前 |
Share data effortlessly with your team
Blazer eliminates the need for many admin pages
Play around with the demo - data from MovieLens
Works with PostgreSQL, MySQL, and Redshift
:tangerine: Battle-tested at Instacart
Add this line to your application’s Gemfile:
gem 'blazer'
Run:
rails g blazer:install
rake db:migrate
And mount the dashboard in your config/routes.rb
:
mount Blazer::Engine, at: "blazer"
For production, specify your database:
ENV["BLAZER_DATABASE_URL"] = "postgres://user:password@hostname:5432/database_name"
It is highly, highly recommended to use a read only user. Keep reading to see how to create one.
Create a user with read only permissions:
BEGIN;
CREATE ROLE blazer LOGIN PASSWORD 'secret123';
GRANT CONNECT ON DATABASE database_name TO blazer;
GRANT USAGE ON SCHEMA public TO blazer;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO blazer;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
COMMIT;
It is recommended to protect sensitive information with views. Documentation coming soon.
Create a user with read only permissions:
GRANT SELECT, SHOW VIEW ON database_name.* TO blazer@’127.0.0.1′ IDENTIFIED BY ‘secret123‘;
FLUSH PRIVILEGES;
It is recommended to protect sensitive information with views. Documentation coming soon.
Don’t forget to protect the dashboard in production.
Set the following variables in your environment or an initializer.
ENV["BLAZER_USERNAME"] = "andrew"
ENV["BLAZER_PASSWORD"] = "secret"
authenticate :user, lambda { |user| user.admin? } do
mount Blazer::Engine, at: "blazer"
end
Set up checks to run every hour.
rake blazer:run_checks
Be sure to set a host in config/environments/production.rb
for emails to work.
config.action_mailer.default_url_options = {host: "blazerme.herokuapp.com"}
We also recommend setting up failing checks to be sent once a day.
rake blazer:send_failing_checks
Add activerecord4-redshift-adapter to your Gemfile and set BLAZER_DATABASE_URL
to redshift://user:pass@host:5439/db
.
For an easy way to group by day, week, month, and more with correct time zones, check out Groupdate.
Change time zone
Blazer.time_zone = "Pacific Time (US & Canada)"
Change timeout PostgreSQL only
Blazer.timeout = 10 # defaults to 15
Turn off audits
Blazer.audit = false
Custom user class
Blazer.user_class = "Admin"
Customize user name
Blazer.user_name = :first_name
Create queries with variables
SELECT COUNT(*) FROM users WHERE gender = {gender}
Supposed you have this query
SELECT COUNT(*) FROM users WHERE city_id = {city_id}
Instead of remembering each city’s id, users can select cities by name.
Add a smart variable with:
smart_variables:
city_id: "SELECT id, name FROM cities ORDER BY name ASC"
The first column is the value of the variable, and the second column is the label.
Link results to other pages in your apps or around the web. Specify a column name and where it should link to. You can use the value of the result with {value}
.
linked_columns:
user_id: "/admin/users/{value}"
ip_address: "http://www.infosniper.net/index.php?ip_address={value}"
SELECT name, city_id FROM users
See which city the user belongs to without a join.
smart_columns:
city_id: "SELECT id, name FROM cities WHERE id IN {value}"
Blazer will automatically generate charts based on the types of the columns returned in your query.
There are two ways to generate line charts.
2+ columns - timestamp, numeric(s)
SELECT gd_week(created_at), COUNT(*) FROM users GROUP BY 1
3 columns - timestamp, string, numeric
SELECT gd_week(created_at), gender, AVG(age) FROM users GROUP BY 1, 2
2 columns - string, numeric
SELECT gender, COUNT(*) FROM users GROUP BY 1
Each query run creates a Blazer::Audit
.
Add a migration for dashboards and checks
rails g migration create_blazer_dashboards
with
create_table :blazer_dashboards do |t|
t.text :name
t.timestamps
end
create_table :blazer_dashboard_queries do |t|
t.references :blazer_dashboard
t.references :blazer_query
t.integer :position
t.timestamps
end
create_table :blazer_checks do |t|
t.references :blazer_query
t.string :state
t.text :emails
t.timestamps
end
View the changelog
Blazer uses a number of awesome, open source projects.
Everyone is encouraged to help improve this project. Here are a few ways you can help: