Class: Railswatch::Reports::ThroughputReport

Inherits:
BaseReport
  • Object
show all
Defined in:
lib/railswatch/reports/throughput_report.rb

Instance Attribute Summary

Attributes inherited from BaseReport

#db, #group, #sort, #title

Instance Method Summary collapse

Methods inherited from BaseReport

#initialize, #nil_data, #nullify_data, #set_defaults, time_in_app_time_zone

Constructor Details

This class inherits a constructor from Railswatch::Reports::BaseReport

Instance Method Details

#dataObject



6
7
8
9
10
11
12
13
# File 'lib/railswatch/reports/throughput_report.rb', line 6

def data
  series = db.pluck(:occurred_at).each_with_object(Hash.new(0)) do |occurred_at, buckets|
    bucket = occurred_at.change(sec: 0, usec: 0).to_i * 1000
    buckets[bucket] += 1
  end

  nullify_data(series.transform_values(&:to_f)).map { |x, y| [x, (y || 0).round(2)] }
end