Class: Blazer::DashboardsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Blazer::DashboardsController
- Defined in:
- app/controllers/blazer/dashboards_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #refresh ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 9 def 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=) && blazer_user if update_dashboard(@dashboard) redirect_to dashboard_path(@dashboard) else render_errors @dashboard end end |
#destroy ⇒ Object
54 55 56 57 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 54 def destroy @dashboard.destroy redirect_to root_path end |
#edit ⇒ Object
43 44 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 43 def edit end |
#new ⇒ Object
5 6 7 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 5 def new @dashboard = Blazer::Dashboard.new end |
#refresh ⇒ Object
59 60 61 62 63 64 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 59 def refresh @dashboard.queries.each do |query| refresh_query(query) end redirect_to dashboard_path(@dashboard, params: variable_params(@dashboard)) end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 22 def show @queries = @dashboard.dashboard_queries.order(:position).preload(:query).map(&:query) @queries.each do |query| @success = process_vars(query.statement_object) end @bind_vars ||= [] @smart_vars = {} @sql_errors = [] @data_sources = @queries.map { |q| Blazer.data_sources[q.data_source] }.uniq @bind_vars.each do |var| @data_sources.each do |data_source| smart_var, error = parse_smart_variables(var, data_source) ((@smart_vars[var] ||= []).concat(smart_var)).uniq! if smart_var @sql_errors << error if error end end add_cohort_analysis_vars if @queries.any?(&:cohort_analysis?) end |
#update ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 46 def update if update_dashboard(@dashboard) redirect_to dashboard_path(@dashboard, params: variable_params(@dashboard)) else render_errors @dashboard end end |