Class: QaServer::PerformanceCalculatorService
- Inherits:
-
Object
- Object
- QaServer::PerformanceCalculatorService
- Includes:
- PerformanceHistoryDataKeys
- Defined in:
- app/services/qa_server/performance_calculator_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
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) ⇒ Hash
Calculate performance statistics for a set of PerformanceHistory records.
-
#initialize(records, action: nil) ⇒ PerformanceCalculatorService
constructor
A new instance of PerformanceCalculatorService.
Constructor Details
#initialize(records, action: nil) ⇒ PerformanceCalculatorService
Returns a new instance of PerformanceCalculatorService.
11 12 13 14 15 |
# File 'app/services/qa_server/performance_calculator_service.rb', line 11 def initialize(records, action: nil) @records = records @action = [:search, :fetch].include?(action) ? action : nil @stats = {} end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
8 9 10 |
# File 'app/services/qa_server/performance_calculator_service.rb', line 8 def action @action end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
8 9 10 |
# File 'app/services/qa_server/performance_calculator_service.rb', line 8 def records @records end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
8 9 10 |
# File 'app/services/qa_server/performance_calculator_service.rb', line 8 def stats @stats end |
Instance Method Details
#calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) ⇒ Hash
Calculate performance statistics for a set of PerformanceHistory records. Min is at the 10th percentile. Max is at the 90th percentile.
23 24 25 26 27 28 29 30 |
# File 'app/services/qa_server/performance_calculator_service.rb', line 23 def calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) # rubocop:disable Metrics/ParameterLists calculate_load_stats(avg, low, high) if load calculate_retrieve_stats(avg, low, high) if load calculate_graph_load_stats(avg, low, high) if load calculate_normalization_stats(avg, low, high) if norm calculate_action_stats(avg, low, high) if full stats end |