Class: RailsPerformance::Reports::RecentRequestsReport
- Inherits:
-
BaseReport
- Object
- BaseReport
- RailsPerformance::Reports::RecentRequestsReport
- Defined in:
- lib/rails_performance/reports/recent_requests_report.rb
Constant Summary collapse
- TIME_WINDOW =
60.minutes
Instance Attribute Summary
Attributes inherited from BaseReport
Instance Method Summary collapse
-
#data(type = :requests) ⇒ Object
most popular type.
- #set_defaults ⇒ Object
Methods inherited from BaseReport
Constructor Details
This class inherits a constructor from RailsPerformance::Reports::BaseReport
Instance Method Details
#data(type = :requests) ⇒ Object
most popular type
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_performance/reports/recent_requests_report.rb', line 10 def data(type = :requests) # most popular type db.data.collect do |record| case type when :requests record_hash(record) when :jobs job_hash(record) end end .select{|e| e if e[:datetime] >= TIME_WINDOW.ago} .sort{|a, b| b[sort] <=> a[sort]} end |
#set_defaults ⇒ Object
6 7 8 |
# File 'lib/rails_performance/reports/recent_requests_report.rb', line 6 def set_defaults @sort ||= :datetime end |