Class: ForemanStatistics::TrendsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ForemanStatistics::TrendsController
- Includes:
- Parameters::Trend
- Defined in:
- app/controllers/foreman_statistics/trends_controller.rb
Instance Method Summary collapse
- #count ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resource_class ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#count ⇒ Object
49 50 51 52 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 49 def count ForemanStatistics::TrendImporter.update! redirect_to trends_url end |
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 19 def create @trend = Trend.build_trend(trend_params) if @trend.save process_success else process_error end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 41 def destroy if @trend.destroy process_success else process_error end end |
#edit ⇒ Object
39 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 39 def edit; end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 7 def index @trends = Trend.types.includes(:trendable).sort_by { |e| e.type_name.downcase }.paginate(:page => params[:page], :per_page => params[:per_page]) end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 11 def new @trend = Trend.new end |
#resource_class ⇒ Object
54 55 56 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 54 def resource_class ForemanStatistics::Trend end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 15 def show render 'foreman_statistics/trends/_empty_data' if @trend.values.joins(:trend_counters).empty? end |
#update ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/foreman_statistics/trends_controller.rb', line 28 def update filter = self.class.trend_params_filter trend_attrs = params[:trend].values.map { |t| filter.filter_params(ActionController::Parameters.new(t), parameter_filter_context, :none) } @trends = Trend.update(params[:trend].keys, trend_attrs).reject { |p| p.errors.empty? } if @trends.empty? process_success else process_error end end |