Class: QaServer::PerformanceGraphDataService
- Inherits:
-
Object
- Object
- QaServer::PerformanceGraphDataService
- Extended by:
- PerformanceHistoryDataKeys
- Defined in:
- app/services/qa_server/performance_graph_data_service.rb
Constant Summary
Constants included from PerformanceHistoryDataKeys
QaServer::PerformanceHistoryDataKeys::ALL_ACTIONS, QaServer::PerformanceHistoryDataKeys::ALL_AUTH, QaServer::PerformanceHistoryDataKeys::AVG_ACTN, QaServer::PerformanceHistoryDataKeys::AVG_FULL, QaServer::PerformanceHistoryDataKeys::AVG_GRPH, QaServer::PerformanceHistoryDataKeys::AVG_LOAD, QaServer::PerformanceHistoryDataKeys::AVG_NORM, QaServer::PerformanceHistoryDataKeys::AVG_RETR, QaServer::PerformanceHistoryDataKeys::BY_DAY, QaServer::PerformanceHistoryDataKeys::BY_HOUR, QaServer::PerformanceHistoryDataKeys::BY_MONTH, QaServer::PerformanceHistoryDataKeys::FETCH, QaServer::PerformanceHistoryDataKeys::FOR_DATATABLE, QaServer::PerformanceHistoryDataKeys::FOR_DAY, QaServer::PerformanceHistoryDataKeys::FOR_MONTH, QaServer::PerformanceHistoryDataKeys::FOR_YEAR, QaServer::PerformanceHistoryDataKeys::HIGH_ACTN, QaServer::PerformanceHistoryDataKeys::HIGH_FULL, QaServer::PerformanceHistoryDataKeys::HIGH_GRPH, QaServer::PerformanceHistoryDataKeys::HIGH_LOAD, QaServer::PerformanceHistoryDataKeys::HIGH_NORM, QaServer::PerformanceHistoryDataKeys::HIGH_RETR, QaServer::PerformanceHistoryDataKeys::LOW_ACTN, QaServer::PerformanceHistoryDataKeys::LOW_FULL, QaServer::PerformanceHistoryDataKeys::LOW_GRPH, QaServer::PerformanceHistoryDataKeys::LOW_LOAD, QaServer::PerformanceHistoryDataKeys::LOW_NORM, QaServer::PerformanceHistoryDataKeys::LOW_RETR, QaServer::PerformanceHistoryDataKeys::SEARCH, QaServer::PerformanceHistoryDataKeys::STATS
Class Method Summary collapse
-
.average_last_12_months(authority_name: nil, action: nil) ⇒ Object
Get daily average for the past 12 months.
-
.average_last_24_hours(authority_name: nil, action: nil) ⇒ Object
Get hourly average for the past 24 hours.
-
.average_last_30_days(authority_name: nil, action: nil) ⇒ Object
Get daily average for the past 30 days.
Class Method Details
.average_last_12_months(authority_name: nil, action: nil) ⇒ Object
Get daily average for the past 12 months.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/services/qa_server/performance_graph_data_service.rb', line 69 def average_last_12_months(authority_name: nil, action: nil) start_month = Time.now.getlocal.beginning_of_month - 11.months avgs = {} 0.upto(11).each do |idx| records = records_by(, action, start_month..start_month.end_of_month) stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false) data = {} data[BY_MONTH] = start_month.strftime("%m-%Y") data[STATS] = stats avgs[idx] = data start_month += 1.month end avgs end |
.average_last_24_hours(authority_name: nil, action: nil) ⇒ Object
Get hourly average for the past 24 hours.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/qa_server/performance_graph_data_service.rb', line 21 def average_last_24_hours(authority_name: nil, action: nil) start_hour = Time.now.getlocal.beginning_of_hour - 23.hours avgs = {} 0.upto(23).each do |idx| records = records_by(, action, start_hour..start_hour.end_of_hour) stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false) data = {} data[BY_HOUR] = performance_by_hour_label(idx, start_hour) data[STATS] = stats avgs[idx] = data start_hour += 1.hour end avgs end |
.average_last_30_days(authority_name: nil, action: nil) ⇒ Object
Get daily average for the past 30 days.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/services/qa_server/performance_graph_data_service.rb', line 45 def average_last_30_days(authority_name: nil, action: nil) start_day = Time.now.getlocal.beginning_of_day - 29.days avgs = {} 0.upto(29).each do |idx| records = records_by(, action, start_day..start_day.end_of_day) stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false) data = {} data[BY_DAY] = performance_by_day_label(idx, start_day) data[STATS] = stats avgs[idx] = data start_day += 1.day end avgs end |