Class: QaServer::PerformanceGraphDataService

Inherits:
Object
  • Object
show all
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::BPMS_GRPH, QaServer::PerformanceHistoryDataKeys::BPMS_NORM, QaServer::PerformanceHistoryDataKeys::BPMS_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::MSPB_GRPH, QaServer::PerformanceHistoryDataKeys::MSPB_NORM, QaServer::PerformanceHistoryDataKeys::MSPB_RETR, QaServer::PerformanceHistoryDataKeys::SEARCH, QaServer::PerformanceHistoryDataKeys::SRC_BYTES, QaServer::PerformanceHistoryDataKeys::STATS

Class Method Summary collapse

Class Method Details

.calculate_last_12_months(authority_name:, action:) ⇒ Object

Performance data for the last 12 months for a specific authority and action

Examples:

returns

{ 0: { month: '09-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  1: { month: '10-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  2: { month: '11-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  ...,
  11: { month: '08-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
}

Parameters:

  • authority_name (String)

    name of an authority

  • action (Symbol)

    :search, :fetch, or :all_actions



23
24
25
26
27
28
29
30
# File 'app/services/qa_server/performance_graph_data_service.rb', line 23

def calculate_last_12_months(authority_name:, action:)
  start_month = QaServer::TimeService.current_time.beginning_of_month - 11.months
  0.upto(11).each_with_object({}) do |idx, averages|
    records = records_by(authority_name, action, start_month..start_month.end_of_month)
    averages[idx] = calculate_from_records(records, BY_MONTH, start_month.strftime("%m-%Y"))
    start_month += 1.month
  end
end

.calculate_last_24_hours(authority_name:, action:) ⇒ Object

Performance data for the last 24 hours for a specific authority and action

Examples:

returns

{ 0: { hour: '1400', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  1: { hour: '1500', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  2: { hour: '1600', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  ...,
  23: { hour: 'NOW', retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
}

Parameters:

  • authority_name (String)

    name of an authority

  • action (Symbol)

    :search, :fetch, or :all_actions



63
64
65
66
67
68
69
70
# File 'app/services/qa_server/performance_graph_data_service.rb', line 63

def calculate_last_24_hours(authority_name:, action:)
  start_hour = QaServer::TimeService.current_time.beginning_of_hour - 23.hours
  0.upto(23).each_with_object({}) do |idx, averages|
    records = records_by(authority_name, action, start_hour..start_hour.end_of_hour)
    averages[idx] = calculate_from_records(records, BY_HOUR, performance_by_hour_label(idx, start_hour))
    start_hour += 1.hour
  end
end

.calculate_last_30_days(authority_name:, action:) ⇒ Object

Performance data for the last 30 days for a specific authority and action

Examples:

returns

{ 0: { day: '07-15-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  1: { day: '07-16-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  2: { day: '07-17-2019', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  ...,
  29: { day: 'TODAY', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
}

Parameters:

  • authority_name (String)

    name of an authority

  • action (Symbol)

    :search, :fetch, or :all_actions



43
44
45
46
47
48
49
50
# File 'app/services/qa_server/performance_graph_data_service.rb', line 43

def calculate_last_30_days(authority_name:, action:)
  start_day = QaServer::TimeService.current_time.beginning_of_day - 29.days
  0.upto(29).each_with_object({}) do |idx, averages|
    records = records_by(authority_name, action, start_day..start_day.end_of_day)
    averages[idx] = calculate_from_records(records, BY_DAY, performance_by_day_label(idx, start_day))
    start_day += 1.day
  end
end

.recalculate_last_hour(authority_name:, action:, averages:) ⇒ Object

Performance data for the last 24 hours for a specific authority and action

Examples:

returns

{ 0: { hour: '1400', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  1: { hour: '1500', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  2: { hour: '1600', stats: { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }},
  ...,
  23: { hour: 'NOW', retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
}

Parameters:

  • authority_name (String)

    name of an authority

  • action (Symbol)

    :search, :fetch, or :all_actions

  • averages (Hash)

    existing data for each hour



84
85
86
87
88
89
# File 'app/services/qa_server/performance_graph_data_service.rb', line 84

def recalculate_last_hour(authority_name:, action:, averages:)
  start_hour = QaServer::TimeService.current_time.beginning_of_hour
  records = records_by(authority_name, action, start_hour..start_hour.end_of_hour)
  averages[23] = calculate_from_records(records, BY_HOUR, performance_by_hour_label(23, start_hour))
  averages
end