Class: SystemMetrics::MetricsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- SystemMetrics::MetricsController
- Defined in:
- app/controllers/system_metrics/metrics_controller.rb
Instance Method Summary collapse
Instance Method Details
#admin ⇒ Object
30 31 32 |
# File 'app/controllers/system_metrics/metrics_controller.rb', line 30 def admin @categories = SystemMetrics::Metric.select('category, count(category) as count').order('category ASC').group('category') end |
#category ⇒ Object
26 27 28 |
# File 'app/controllers/system_metrics/metrics_controller.rb', line 26 def category @metrics = SystemMetrics::Metric.where(:category => params[:category], :started_at => date_range).order('duration DESC').limit(limit) end |
#destroy ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/system_metrics/metrics_controller.rb', line 15 def destroy category = params[:id] if category == 'all' SystemMetrics::Metric.delete_all else SystemMetrics::Metric.where(:category => category).delete_all end redirect_to system_metrics_admin_path end |
#index ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/controllers/system_metrics/metrics_controller.rb', line 3 def index @category_metrics = {} categories = SystemMetrics::Metric.select('DISTINCT(category)').order('category ASC').map(&:category) categories.each do |category| @category_metrics[category] = SystemMetrics::Metric.where(:category => category, :started_at => date_range).order('duration DESC').limit(limit(10)) end end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/system_metrics/metrics_controller.rb', line 11 def show @metric = SystemMetrics::Metric.find(params[:id]) end |