Class: SimpleApm::Summary
- Inherits:
-
Object
- Object
- SimpleApm::Summary
- Defined in:
- app/models/simple_apm/summary.rb
Constant Summary collapse
- @@results =
{}
Instance Method Summary collapse
-
#initialize(date) ⇒ Summary
constructor
A new instance of Summary.
- #result ⇒ Object
Constructor Details
#initialize(date) ⇒ Summary
Returns a new instance of Summary.
5 6 7 |
# File 'app/models/simple_apm/summary.rb', line 5 def initialize(date) @date = date end |
Instance Method Details
#result ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/simple_apm/summary.rb', line 9 def result return @@results[@date] if @@results[@date] && Time.parse(@date) < Date.today @@results[@date] = SimpleApm::RedisKey.set_query_date(@date) do res = SimpleApm::Hit.day_info(@date) actions = SimpleApm::Action.all_names.map{|n|SimpleApm::Action.find(n)} most_hits_5 = actions.sort_by{|x|x.click_count.to_i}.reverse.take(5) most_hits_5.map! do |action| { name: action.name, avg_time: action.avg_time, hits: action.click_count.to_i, slow_avg_time: action.slow_requests.sum(&:during)/action.slow_requests.length } end { hits: res[:hits], avg_time: res[:avg_time], actions: most_hits_5 } end end |