Business intelligence made simple
Added creator to dashboards and checks
Andrew Kane25a50f9f51f2
diff --git a/app/controllers/blazer/checks_controller.rb b/app/controllers/blazer/checks_controller.rbindex 673de010..695c314c 100644--- a/app/controllers/blazer/checks_controller.rb+++ b/app/controllers/blazer/checks_controller.rb@@ -13,6 +13,9 @@ module Blazerdef create@check = Blazer::Check.new(check_params)+ # use creator_id instead of creator+ # since we setup association without checking if column exists+ @check.creator = blazer_user if @check.respond_to?(:creator_id=)if @check.saveredirect_to run_check_path(@check)diff --git a/app/controllers/blazer/dashboards_controller.rb b/app/controllers/blazer/dashboards_controller.rbindex 368612a6..cdc1eb7b 100644--- a/app/controllers/blazer/dashboards_controller.rb+++ b/app/controllers/blazer/dashboards_controller.rb@@ -12,6 +12,9 @@ module Blazerdef create@dashboard = Blazer::Dashboard.new+ # use creator_id instead of creator+ # since we setup association without checking if column exists+ @dashboard.creator = blazer_user if @dashboard.respond_to?(:creator_id=)if update_dashboard(@dashboard)redirect_to dashboard_path(@dashboard)diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 50f49ef0..855ce0aa 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -8,7 +8,7 @@ module BlazerBlazer::Dashboard.order(:name).map do |d|{name: "<strong>#{view_context.link_to(d.name, d)}</strong>",- creator: nil,+ creator: d.respond_to?(:creator) && d.creator == blazer_user ? "You" : d.try(:creator).try(Blazer.user_name),hide: d.name.gsub(/\s+/, ""),vars: nil}diff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex 597c9e03..bb307ce3 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -21,7 +21,11 @@ module BlazerBlazer.check_schedules = Blazer.settings["check_schedules"] if Blazer.settings.key?("check_schedules")- Blazer::Query.belongs_to :creator, class_name: Blazer.user_class.to_s if Blazer.user_class+ if Blazer.user_class+ Blazer::Query.belongs_to :creator, class_name: Blazer.user_class.to_s+ Blazer::Dashboard.belongs_to :creator, class_name: Blazer.user_class.to_s+ Blazer::Check.belongs_to :creator, class_name: Blazer.user_class.to_s+ endBlazer.cache ||= Rails.cacheenddiff --git a/lib/generators/blazer/templates/install.rb b/lib/generators/blazer/templates/install.rbindex 568551fe..f463f6a9 100644--- a/lib/generators/blazer/templates/install.rb+++ b/lib/generators/blazer/templates/install.rb@@ -18,6 +18,7 @@ class <%= migration_class_name %> < ActiveRecord::Migrationendcreate_table :blazer_dashboards do |t|+ t.refrences :creatort.text :namet.timestampsend@@ -30,6 +31,7 @@ class <%= migration_class_name %> < ActiveRecord::Migrationendcreate_table :blazer_checks do |t|+ t.references :creatort.references :queryt.string :statet.string :schedule