Sha256: 845360f14a5086a0bc4b31489a30f0397cdb81c78509cc19324652c0055e91cd

Contents?: true

Size: 1009 Bytes

Versions: 5

Compression:

Stored size: 1009 Bytes

Contents

module ActiveRecordProfiler
  class ReportsController < ActiveRecordProfiler::ApplicationController
    include ReportsHelper

    def index
      @report_options = report_options(params)
      collector = ActiveRecordProfiler::Collector.new
      @totals = collector.aggregate(:prefix => @report_options[:date])
      @top_locations = collector.sorted_locations(@report_options[:sort], 
          @report_options[:max_rows])
      top_item = @totals[@top_locations.first]
      @max_bar_value = bar_value(@report_options[:sort], top_item)
    end

    private
      def report_options(page_params)
        options = page_params.reverse_merge(
            :date => Time.now.strftime(Collector::DATE_FORMAT),
            :sort => Collector::DURATION,
            :max_rows => 100
        )
        
        options[:sort] = options[:sort].to_i
        options[:max_rows] = options[:max_rows].to_i
        options[:link_location] = ActiveRecordProfiler.link_location

        return options
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active-record-profiler-2.0.0 app/controllers/active_record_profiler/reports_controller.rb
active-record-profiler-1.2.1 app/controllers/active_record_profiler/reports_controller.rb
active-record-profiler-1.2.0 app/controllers/active_record_profiler/reports_controller.rb
active-record-profiler-1.1.0 app/controllers/active_record_profiler/reports_controller.rb
active-record-profiler-1.0 app/controllers/active_record_profiler/reports_controller.rb