qa_server 2.2.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/app/assets/stylesheets/qa_server/_authorities.scss +4 -1
  4. data/app/assets/stylesheets/qa_server/_check-status.scss +5 -0
  5. data/app/assets/stylesheets/qa_server/_monitor-status.scss +2 -2
  6. data/app/models/concerns/qa_server/performance_history_data_keys.rb +16 -3
  7. data/app/models/qa_server/performance_history.rb +54 -46
  8. data/app/prepends/prepended_linked_data/find_term.rb +51 -9
  9. data/app/prepends/prepended_linked_data/search_query.rb +37 -9
  10. data/app/prepends/prepended_rdf/rdf_graph.rb +55 -0
  11. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +55 -21
  12. data/app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb +54 -25
  13. data/app/presenters/qa_server/monitor_status_presenter.rb +11 -8
  14. data/app/services/qa_server/performance_calculator_service.rb +50 -47
  15. data/app/services/qa_server/performance_graph_data_service.rb +13 -12
  16. data/app/services/qa_server/performance_graphing_service.rb +49 -40
  17. data/app/views/qa_server/monitor_status/_performance.html.erb +107 -32
  18. data/config/locales/qa_server.en.yml +9 -2
  19. data/lib/generators/qa_server/config_generator.rb +1 -0
  20. data/lib/generators/qa_server/templates/config/authorities/linked_data/agrovoc_ld4l_cache.json +8 -1
  21. data/lib/generators/qa_server/templates/config/authorities/linked_data/dbpedia_ld4l_cache.json +8 -1
  22. data/lib/generators/qa_server/templates/config/authorities/linked_data/geonames_ld4l_cache.json +11 -1
  23. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json +8 -1
  24. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +8 -1
  25. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_ulan_ld4l_cache.json +8 -1
  26. data/lib/generators/qa_server/templates/config/authorities/linked_data/locdemographics_ld4l_cache.json +2 -1
  27. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_ld4l_cache.json +51 -42
  28. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo_ld4l_cache.json +237 -0
  29. data/lib/generators/qa_server/templates/config/authorities/linked_data/locperformance_ld4l_cache.json +75 -3
  30. data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +8 -1
  31. data/lib/generators/qa_server/templates/config/authorities/linked_data/nalt_ld4l_cache.json +8 -1
  32. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +8 -1
  33. data/lib/generators/qa_server/templates/config/authorities/linked_data/rda_registry_ld4l_cache.json +193 -0
  34. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +3 -18
  35. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +27 -0
  36. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml +1 -0
  37. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +255 -0
  38. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/wikidata_direct_validation.yml +6 -0
  39. data/lib/generators/qa_server/templates/config/authorities/linked_data/wikidata_direct.json +32 -0
  40. data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +14 -5
  41. data/lib/generators/qa_server/templates/db/migrate/20191007134527_update_performance_history_table.rb.erb +19 -0
  42. data/lib/qa_server/configuration.rb +27 -5
  43. data/lib/qa_server/version.rb +1 -1
  44. metadata +10 -2
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  # This module provides methods for creating and accessing performance graphs.
3
3
  module QaServer::MonitorStatus
4
- module PerformanceGraphBehavior
4
+ module PerformanceGraphBehavior # rubocop:disable Metrics/ModuleLength
5
5
  include QaServer::PerformanceHistoryDataKeys
6
6
  include QaServer::MonitorStatus::GruffGraph
7
7
 
@@ -29,12 +29,20 @@ module QaServer::MonitorStatus
29
29
  "performance-for-day-#{ALL_AUTH}"
30
30
  end
31
31
 
32
+ def performance_graph_time_period(graph_info)
33
+ graph_info[:time_period]
34
+ end
35
+
36
+ def performance_graph_action(graph_info)
37
+ graph_info[:action]
38
+ end
39
+
32
40
  def performance_graph_id(graph_info)
33
- "#{graph_info[:base_id]}-during-#{graph_info[:time_period]}-chart"
41
+ "#{graph_info[:base_id]}-#{performance_graph_action(graph_info)}-during-#{performance_graph_time_period(graph_info)}-chart"
34
42
  end
35
43
 
36
44
  def performance_graph_data_section_id(graph_info)
37
- "#{graph_info[:base_id]}-during-#{graph_info[:time_period]}"
45
+ "#{graph_info[:base_id]}-#{performance_graph_action(graph_info)}-during-#{performance_graph_time_period(graph_info)}"
38
46
  end
39
47
 
40
48
  def performance_graph_data_section_base_id(graph_info)
@@ -46,63 +54,84 @@ module QaServer::MonitorStatus
46
54
  'performance-data-section-hidden'
47
55
  end
48
56
 
49
- def performance_day_graph_selected?(graph_info)
50
- return true if graph_info[:time_period] == :day
57
+ def performance_day_graph?(graph_info)
58
+ return true if performance_graph_time_period(graph_info) == :day
59
+ false
60
+ end
61
+
62
+ def performance_month_graph?(graph_info)
63
+ return true if performance_graph_time_period(graph_info) == :month
64
+ false
65
+ end
66
+
67
+ def performance_year_graph?(graph_info)
68
+ return true if performance_graph_time_period(graph_info) == :year
69
+ false
70
+ end
71
+
72
+ def performance_all_actions_graph?(graph_info)
73
+ return true if performance_graph_action(graph_info) == :all_actions
51
74
  false
52
75
  end
53
76
 
54
- def performance_month_graph_selected?(graph_info)
55
- return true if graph_info[:time_period] == :month
77
+ def performance_search_graph?(graph_info)
78
+ return true if performance_graph_action(graph_info) == :search
56
79
  false
57
80
  end
58
81
 
59
- def performance_year_graph_selected?(graph_info)
60
- return true if graph_info[:time_period] == :year
82
+ def performance_fetch_graph?(graph_info)
83
+ return true if performance_graph_action(graph_info) == :fetch
61
84
  false
62
85
  end
63
86
 
64
87
  private
65
88
 
66
- def default_graph?(graph_info) # rubocop:disable Metrics/CyclomaticComplexity
67
- return true if QaServer.config.performance_graph_default_time_period == :day && performance_day_graph_selected?(graph_info)
68
- return true if QaServer.config.performance_graph_default_time_period == :month && performance_month_graph_selected?(graph_info)
69
- return true if QaServer.config.performance_graph_default_time_period == :year && performance_year_graph_selected?(graph_info)
89
+ def default_graph?(graph_info) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
90
+ return false unless performance_all_actions_graph?(graph_info)
91
+ return true if QaServer.config.performance_graph_default_time_period == :day && performance_day_graph?(graph_info)
92
+ return true if QaServer.config.performance_graph_default_time_period == :month && performance_month_graph?(graph_info)
93
+ return true if QaServer.config.performance_graph_default_time_period == :year && performance_year_graph?(graph_info)
70
94
  false
71
95
  end
72
96
 
73
97
  def performance_graphs_for_authority(graphs, auth_name)
74
- graphs << performance_for_day_graph(auth_name)
75
- graphs << performance_for_month_graph(auth_name)
76
- graphs << performance_for_year_graph(auth_name)
98
+ [:search, :fetch, :all_actions].each do |action|
99
+ graphs << performance_for_day_graph(auth_name, action)
100
+ graphs << performance_for_month_graph(auth_name, action)
101
+ graphs << performance_for_year_graph(auth_name, action)
102
+ end
77
103
  end
78
104
 
79
- def performance_for_day_graph(auth_name)
105
+ def performance_for_day_graph(auth_name, action)
80
106
  {
107
+ action: action,
81
108
  time_period: :day,
82
- graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, time_period: :day),
109
+ graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, action: action, time_period: :day),
83
110
  label: "Performance data for the last 24 hours.",
84
111
  authority_name: auth_name,
85
- base_id: "performance-for-#{auth_name}"
112
+ base_id: "performance-of-#{auth_name}"
86
113
  }
87
114
  end
88
115
 
89
- def performance_for_month_graph(auth_name)
116
+ def performance_for_month_graph(auth_name, action)
90
117
  {
118
+ action: action,
91
119
  time_period: :month,
92
- graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, time_period: :month),
120
+ graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, action: action, time_period: :month),
93
121
  label: "Performance data for the last 30 days.",
94
122
  authority_name: auth_name,
95
- base_id: "performance-for-#{auth_name}"
123
+ base_id: "performance-of-#{auth_name}"
96
124
  }
97
125
  end
98
126
 
99
- def performance_for_year_graph(auth_name)
127
+ def performance_for_year_graph(auth_name, action)
100
128
  {
129
+ action: action,
101
130
  time_period: :year,
102
- graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, time_period: :year),
131
+ graph: QaServer::PerformanceGraphingService.performance_graph_file(authority_name: auth_name, action: action, time_period: :year),
103
132
  label: "Performance data for the last 12 months.",
104
133
  authority_name: auth_name,
105
- base_id: "performance-for-#{auth_name}"
134
+ base_id: "performance-of-#{auth_name}"
106
135
  }
107
136
  end
108
137
  end
@@ -25,13 +25,16 @@ module QaServer
25
25
 
26
26
  def_delegators :@performance_presenter, :performance_data, :performance_data?, :display_performance?, :display_performance_graph?,
27
27
  :display_performance_datatable?, :performance_data_authority_name, :performance_for_day_graph, :performance_for_month_graph,
28
- :performance_for_year_graph, :datatable_stats, :low_load, :low_normalization, :low_full_request, :high_load,
29
- :high_normalization, :high_full_request, :avg_load, :avg_normalization, :avg_full_request, :low_load_style,
30
- :low_normalization_style, :low_full_request_style, :high_load_style, :high_normalization_style, :high_full_request_style,
31
- :avg_load_style, :avg_normalization_style, :avg_full_request_style, :performance_style_class, :high_threshold_exceeded,
32
- :low_threshold_not_met, :performance_graphs, :performance_graph, :performance_graph_authority, :performance_graph_label,
33
- :performance_default_graph_id, :performance_graph_id, :performance_graph_data_section_id, :performance_graph_data_section_base_id,
34
- :performance_data_section_class, :performance_day_graph_selected?, :performance_month_graph_selected?,
35
- :performance_year_graph_selected?, :performance_table_description
28
+ :performance_for_year_graph, :datatable_search_stats, :datatable_fetch_stats, :datatable_all_actions_stats,
29
+ :low_retrieve, :low_graph_load, :low_normalization, :low_full_request, :high_retrieve, :high_graph_load,
30
+ :high_normalization, :high_full_request, :avg_retrieve, :avg_graph_load, :avg_normalization, :avg_full_request,
31
+ :datatable_data_style, :low_load_style, :low_normalization_style, :low_full_request_style, :high_load_style,
32
+ :high_normalization_style, :high_full_request_style, :avg_load_style, :avg_normalization_style, :avg_full_request_style,
33
+ :performance_style_class, :high_threshold_exceeded, :low_threshold_not_met, :performance_graphs, :performance_graph,
34
+ :performance_graph_authority, :performance_graph_label, :performance_default_graph_id, :performance_graph_id,
35
+ :performance_graph_data_section_id, :performance_graph_data_section_base_id, :performance_data_section_class,
36
+ :performance_day_graph?, :performance_month_graph?, :performance_year_graph?, :performance_all_actions_graph?,
37
+ :performance_search_graph?, :performance_fetch_graph?, :performance_table_description, :performance_graph_time_period,
38
+ :performance_graph_action
36
39
  end
37
40
  end
@@ -5,99 +5,102 @@ module QaServer
5
5
  class PerformanceCalculatorService
6
6
  include QaServer::PerformanceHistoryDataKeys
7
7
 
8
- attr_reader :records
9
- attr_reader :stats
8
+ attr_reader :records, :stats, :action
10
9
 
11
10
  # @param records [Array <Qa::PerformanceHistory>] set of records used to calculate the statistics
12
- def initialize(records)
11
+ def initialize(records, action: nil)
13
12
  @records = records
13
+ @action = [:search, :fetch].include?(action) ? action : nil
14
14
  @stats = {}
15
15
  end
16
16
 
17
17
  # Calculate performance statistics for a set of PerformanceHistory records. Min is at the 10th percentile. Max is at the 90th percentile.
18
18
  # @return [Hash] hash of the statistics
19
19
  # @example
20
- # { load_avg_ms: 12.3, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5,
21
- # load_min_ms: 12.3, normalization_min_ms: 4.2, full_request_min_ms: 16.5,
22
- # load_max_ms: 12.3, normalization_max_ms: 4.2, full_request_max_ms: 16.5 }
20
+ # { retrieve_avg_ms: 12.3, graph_load_avg_ms: 2.1, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5,
21
+ # retrieve_10th_ms: 12.3, graph_load_10th_ms: 12.3, normalization_10th_ms: 4.2, full_request_10th_ms: 16.5,
22
+ # retrieve_90th_ms: 12.3, graph_load_90th_ms: 12.3, normalization_90th_ms: 4.2, full_request_90th_ms: 16.5 }
23
23
  def calculate_stats(avg: false, low: false, high: false, load: true, norm: true, full: true) # rubocop:disable Metrics/ParameterLists
24
- calculate_load_stats(avg, low, high) if load
25
- calculate_norm_stats(avg, low, high) if norm
26
- calculate_full_stats(avg, low, high) if full
24
+ calculate_retrieve_stats(avg, low, high) if load
25
+ calculate_graph_load_stats(avg, low, high) if load
26
+ calculate_normalization_stats(avg, low, high) if norm
27
+ calculate_action_stats(avg, low, high) if full
27
28
  stats
28
29
  end
29
30
 
30
31
  private
31
32
 
32
- def calculate_load_stats(avg, low, high)
33
- stats[AVG_LOAD] = calculate_average(load_times) if avg
34
- stats[LOW_LOAD] = calculate_10th_percentile(load_times_sorted) if low
35
- stats[HIGH_LOAD] = calculate_90th_percentile(load_times_sorted) if high
33
+ def calculate_retrieve_stats(avg, low, high)
34
+ stats[AVG_RETR] = calculate_average(retrieve_times) if avg
35
+ stats[LOW_RETR] = calculate_10th_percentile(retrieve_times) if low
36
+ stats[HIGH_RETR] = calculate_90th_percentile(retrieve_times) if high
36
37
  end
37
38
 
38
- def calculate_norm_stats(avg, low, high)
39
+ def calculate_graph_load_stats(avg, low, high)
40
+ stats[AVG_GRPH] = calculate_average(graph_load_times) if avg
41
+ stats[LOW_GRPH] = calculate_10th_percentile(graph_load_times) if low
42
+ stats[HIGH_GRPH] = calculate_90th_percentile(graph_load_times) if high
43
+ end
44
+
45
+ def calculate_normalization_stats(avg, low, high)
39
46
  stats[AVG_NORM] = calculate_average(norm_times) if avg
40
- stats[LOW_NORM] = calculate_10th_percentile(norm_times_sorted) if low
41
- stats[HIGH_NORM] = calculate_90th_percentile(norm_times_sorted) if high
47
+ stats[LOW_NORM] = calculate_10th_percentile(norm_times) if low
48
+ stats[HIGH_NORM] = calculate_90th_percentile(norm_times) if high
42
49
  end
43
50
 
44
- def calculate_full_stats(avg, low, high)
45
- stats[AVG_FULL] = calculate_average(full_times) if avg
46
- stats[LOW_FULL] = calculate_10th_percentile(full_times_sorted) if low
47
- stats[HIGH_FULL] = calculate_90th_percentile(full_times_sorted) if high
51
+ def calculate_action_stats(avg, low, high)
52
+ stats[AVG_ACTN] = calculate_average(action_times) if avg
53
+ stats[LOW_ACTN] = calculate_10th_percentile(action_times) if low
54
+ stats[HIGH_ACTN] = calculate_90th_percentile(action_times) if high
48
55
  end
49
56
 
50
57
  def count
51
58
  @count ||= records.count
52
59
  end
53
60
 
54
- def tenth_percentile_count
55
- return @tenth_percentile_count if @tenth_percentile_count.present?
56
- percentile_count = (count * 0.1).round
61
+ def tenth_percentile_count(times)
62
+ percentile_count = (times.count * 0.1).round
57
63
  percentile_count = 1 if percentile_count.zero? && count > 1
58
- @tenth_percentile_count = percentile_count
59
- end
60
-
61
- def load_times
62
- @load_times ||= records.pluck(:load_time_ms).to_a
64
+ percentile_count
63
65
  end
64
66
 
65
- def load_times_sorted
66
- @load_times_sorted ||= load_times.sort
67
+ def times(column)
68
+ where_clause = action.nil? ? "" : { "action" => action }
69
+ records.where(where_clause).where.not(column => nil).order(column).pluck(column)
67
70
  end
68
71
 
69
- def norm_times
70
- @norm_times ||= records.pluck(:normalization_time_ms).to_a
72
+ def retrieve_times
73
+ @retrieve_times ||= times(:retrieve_time_ms)
71
74
  end
72
75
 
73
- def norm_times_sorted
74
- @norm_times_sorted ||= norm_times.sort
76
+ def graph_load_times
77
+ @graph_load_times ||= times(:graph_load_time_ms)
75
78
  end
76
79
 
77
- def full_times
78
- @full_times ||= (Vector.elements(load_times) + Vector.elements(norm_times)).to_a
80
+ def norm_times
81
+ @norm_times ||= times(:normalization_time_ms)
79
82
  end
80
83
 
81
- def full_times_sorted
82
- @full_times_sorted ||= full_times.sort
84
+ def action_times
85
+ @action_times ||= times(:action_time_ms)
83
86
  end
84
87
 
85
88
  def calculate_average(times)
86
89
  return 0 if count.zero?
87
90
  return times[0] if count == 1
88
- times.inject(0.0) { |sum, el| sum + el } / count
91
+ times.inject(0.0) { |sum, el| sum + el } / times.count
89
92
  end
90
93
 
91
- def calculate_10th_percentile(sorted_times)
92
- return 0 if count.zero?
93
- return sorted_times[0] if count == 1
94
- sorted_times[tenth_percentile_count - 1]
94
+ def calculate_10th_percentile(times)
95
+ return 0 if times.count.zero?
96
+ return times[0] if times.count == 1
97
+ times[tenth_percentile_count(times) - 1]
95
98
  end
96
99
 
97
- def calculate_90th_percentile(sorted_times)
98
- return 0 if count.zero?
99
- return sorted_times[0] if count == 1
100
- sorted_times[count - tenth_percentile_count]
100
+ def calculate_90th_percentile(times)
101
+ return 0 if times.count.zero?
102
+ return times[0] if times.count == 1
103
+ times[times.count - tenth_percentile_count(times)]
101
104
  end
102
105
  end
103
106
  end
@@ -18,13 +18,11 @@ module QaServer
18
18
  # ...,
19
19
  # 23: { hour: 'NOW', stats: { load_avg_ms: 12.3, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
20
20
  # }
21
- def average_last_24_hours(auth_name = nil)
21
+ def average_last_24_hours(authority_name: nil, action: nil)
22
22
  start_hour = Time.now.getlocal.beginning_of_hour - 23.hours
23
23
  avgs = {}
24
24
  0.upto(23).each do |idx|
25
- where_clause = { dt_stamp: start_hour..start_hour.end_of_hour }
26
- where_clause[:authority] = auth_name unless auth_name.nil?
27
- records = performance_data_class.where(where_clause)
25
+ records = records_by(authority_name, action, start_hour..start_hour.end_of_hour)
28
26
  stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false)
29
27
  data = {}
30
28
  data[BY_HOUR] = performance_by_hour_label(idx, start_hour)
@@ -44,13 +42,11 @@ module QaServer
44
42
  # ...,
45
43
  # 29: { day: 'TODAY', stats: { load_avg_ms: 12.3, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
46
44
  # }
47
- def average_last_30_days(auth_name = nil)
45
+ def average_last_30_days(authority_name: nil, action: nil)
48
46
  start_day = Time.now.getlocal.beginning_of_day - 29.days
49
47
  avgs = {}
50
48
  0.upto(29).each do |idx|
51
- where_clause = { dt_stamp: start_day..start_day.end_of_day }
52
- where_clause[:authority] = auth_name unless auth_name.nil?
53
- records = performance_data_class.where(where_clause)
49
+ records = records_by(authority_name, action, start_day..start_day.end_of_day)
54
50
  stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false)
55
51
  data = {}
56
52
  data[BY_DAY] = performance_by_day_label(idx, start_day)
@@ -70,13 +66,11 @@ module QaServer
70
66
  # ...,
71
67
  # 11: { month: '08-2019', stats: { load_avg_ms: 12.3, normalization_avg_ms: 4.2, full_request_avg_ms: 16.5, etc. }}
72
68
  # }
73
- def average_last_12_months(auth_name = nil)
69
+ def average_last_12_months(authority_name: nil, action: nil)
74
70
  start_month = Time.now.getlocal.beginning_of_month - 11.months
75
71
  avgs = {}
76
72
  0.upto(11).each do |idx|
77
- where_clause = { dt_stamp: start_month..start_month.end_of_month }
78
- where_clause[:authority] = auth_name unless auth_name.nil?
79
- records = performance_data_class.where(where_clause)
73
+ records = records_by(authority_name, action, start_month..start_month.end_of_month)
80
74
  stats = stats_calculator_class.new(records).calculate_stats(avg: true, full: false)
81
75
  data = {}
82
76
  data[BY_MONTH] = start_month.strftime("%m-%Y")
@@ -89,6 +83,13 @@ module QaServer
89
83
 
90
84
  private
91
85
 
86
+ def records_by(authority_name, action, time_period)
87
+ where_clause = { dt_stamp: time_period }
88
+ where_clause[:authority] = authority_name unless authority_name.nil?
89
+ where_clause[:action] = action unless action.nil? || action == :all_actions
90
+ performance_data_class.where(where_clause)
91
+ end
92
+
92
93
  def performance_by_hour_label(idx, start_hour)
93
94
  if idx == 23
94
95
  I18n.t('qa_server.monitor_status.performance.now')
@@ -12,45 +12,50 @@ module QaServer
12
12
  # @param performance_data [Hash] hash of all performance data for all authorities
13
13
  # @see QaServer:PerformanceHistory
14
14
  def create_performance_graphs(performance_data:)
15
- performance_data.each_key { |auth_name| create_graphs_for_authority(performance_data, auth_name.to_sym) }
15
+ performance_data.each_key do |auth_name|
16
+ create_graphs_for_authority(performance_data, auth_name.to_sym, :search)
17
+ create_graphs_for_authority(performance_data, auth_name.to_sym, :fetch)
18
+ create_graphs_for_authority(performance_data, auth_name.to_sym, :all_actions)
19
+ end
16
20
  end
17
21
 
18
22
  # @param authority_name [String] name of the authority
23
+ # @param action [Symbol] action performed by the request (e.g. :search, :fetch, :all_actions)
19
24
  # @param time_period [Symbol] time period for the graph (i.e. :day, :month, :year)
20
- def performance_graph_file(authority_name: ALL_AUTH, time_period:)
21
- File.join(graph_relative_path, graph_filename(authority_name, time_period))
25
+ def performance_graph_file(authority_name: ALL_AUTH, action:, time_period:)
26
+ File.join(graph_relative_path, graph_filename(authority_name, action, time_period))
22
27
  end
23
28
 
24
29
  private
25
30
 
26
- def create_graphs_for_authority(performance_data, authority_name)
27
- create_performance_for_day_graph(performance_data, authority_name)
28
- create_performance_for_month_graph(performance_data, authority_name)
29
- create_performance_for_year_graph(performance_data, authority_name)
31
+ def create_graphs_for_authority(performance_data, authority_name, action)
32
+ create_performance_for_day_graph(performance_data, authority_name, action)
33
+ create_performance_for_month_graph(performance_data, authority_name, action)
34
+ create_performance_for_year_graph(performance_data, authority_name, action)
30
35
  end
31
36
 
32
- def create_performance_for_day_graph(performance_data, authority_name)
37
+ def create_performance_for_day_graph(performance_data, authority_name, action)
33
38
  auth_data = authority_performance_data(performance_data, authority_name)
34
39
  return unless auth_data
35
- gruff_data = rework_performance_data_for_gruff(auth_data[FOR_DAY], BY_HOUR)
40
+ gruff_data = rework_performance_data_for_gruff(auth_data[action][FOR_DAY], BY_HOUR)
36
41
  create_gruff_graph(gruff_data,
37
- performance_for_day_graph_full_path(authority_name),
42
+ performance_for_day_graph_full_path(authority_name, action),
38
43
  I18n.t('qa_server.monitor_status.performance.x_axis_hour'))
39
44
  end
40
45
 
41
- def create_performance_for_month_graph(performance_data, authority_name)
46
+ def create_performance_for_month_graph(performance_data, authority_name, action)
42
47
  auth_data = authority_performance_data(performance_data, authority_name)
43
- gruff_data = rework_performance_data_for_gruff(auth_data[FOR_MONTH], BY_DAY)
48
+ gruff_data = rework_performance_data_for_gruff(auth_data[action][FOR_MONTH], BY_DAY)
44
49
  create_gruff_graph(gruff_data,
45
- performance_for_month_graph_full_path(authority_name),
50
+ performance_for_month_graph_full_path(authority_name, action),
46
51
  I18n.t('qa_server.monitor_status.performance.x_axis_day'))
47
52
  end
48
53
 
49
- def create_performance_for_year_graph(performance_data, authority_name)
54
+ def create_performance_for_year_graph(performance_data, authority_name, action)
50
55
  auth_data = authority_performance_data(performance_data, authority_name)
51
- gruff_data = rework_performance_data_for_gruff(auth_data[FOR_YEAR], BY_MONTH)
56
+ gruff_data = rework_performance_data_for_gruff(auth_data[action][FOR_YEAR], BY_MONTH)
52
57
  create_gruff_graph(gruff_data,
53
- performance_for_year_graph_full_path(authority_name),
58
+ performance_for_year_graph_full_path(authority_name, action),
54
59
  I18n.t('qa_server.monitor_status.performance.x_axis_month'))
55
60
  end
56
61
 
@@ -59,44 +64,47 @@ module QaServer
59
64
  data[auth_name]
60
65
  end
61
66
 
62
- def performance_graph_theme(g, x_axis_label)
63
- g.theme_pastel
64
- g.colors = [QaServer.config.performance_normalization_color,
65
- QaServer.config.performance_load_color]
66
- g.marker_font_size = 12
67
- g.x_axis_increment = 10
68
- g.x_axis_label = x_axis_label
69
- g.y_axis_label = I18n.t('qa_server.monitor_status.performance.y_axis_ms')
70
- g.minimum_value = 0
71
- g.maximum_value = 2000
72
- end
73
-
74
- def performance_for_day_graph_full_path(authority_name)
75
- graph_full_path(graph_filename(authority_name, :day))
67
+ def performance_for_day_graph_full_path(authority_name, action)
68
+ graph_full_path(graph_filename(authority_name, action, :day))
76
69
  end
77
70
 
78
- def performance_for_month_graph_full_path(authority_name)
79
- graph_full_path(graph_filename(authority_name, :month))
71
+ def performance_for_month_graph_full_path(authority_name, action)
72
+ graph_full_path(graph_filename(authority_name, action, :month))
80
73
  end
81
74
 
82
- def performance_for_year_graph_full_path(authority_name)
83
- graph_full_path(graph_filename(authority_name, :year))
75
+ def performance_for_year_graph_full_path(authority_name, action)
76
+ graph_full_path(graph_filename(authority_name, action, :year))
84
77
  end
85
78
 
86
- def graph_filename(authority_name, time_period)
87
- "performance_of_#{authority_name}_for_#{time_period}_graph.png"
79
+ def graph_filename(authority_name, action, time_period)
80
+ "performance_of_#{authority_name}_#{action}_for_#{time_period}_graph.png"
88
81
  end
89
82
 
90
83
  def rework_performance_data_for_gruff(performance_data, label_key)
91
84
  labels = {}
92
- load_data = []
85
+ retrieve_data = []
86
+ graph_load_data = []
93
87
  normalization_data = []
94
88
  performance_data.each do |i, data|
95
89
  labels[i] = data[label_key]
96
- load_data << data[STATS][AVG_LOAD]
90
+ retrieve_data << data[STATS][AVG_RETR]
91
+ graph_load_data << data[STATS][AVG_GRPH]
97
92
  normalization_data << data[STATS][AVG_NORM]
98
93
  end
99
- [labels, normalization_data, load_data]
94
+ [labels, normalization_data, graph_load_data, retrieve_data]
95
+ end
96
+
97
+ def performance_graph_theme(g, x_axis_label)
98
+ g.theme_pastel
99
+ g.colors = [QaServer.config.performance_normalization_color,
100
+ QaServer.config.performance_graph_load_color,
101
+ QaServer.config.performance_retrieve_color]
102
+ g.marker_font_size = 12
103
+ g.x_axis_increment = 10
104
+ g.x_axis_label = x_axis_label
105
+ g.y_axis_label = I18n.t('qa_server.monitor_status.performance.y_axis_ms')
106
+ g.minimum_value = 0
107
+ g.maximum_value = QaServer.config.performance_y_axis_max
100
108
  end
101
109
 
102
110
  def create_gruff_graph(performance_data, performance_graph_full_path, x_axis_label)
@@ -105,7 +113,8 @@ module QaServer
105
113
  g.title = ''
106
114
  g.labels = performance_data[0]
107
115
  g.data(I18n.t('qa_server.monitor_status.performance.normalization_time_ms'), performance_data[1])
108
- g.data(I18n.t('qa_server.monitor_status.performance.load_time_ms'), performance_data[2])
116
+ g.data(I18n.t('qa_server.monitor_status.performance.graph_load_time_ms'), performance_data[2])
117
+ g.data(I18n.t('qa_server.monitor_status.performance.retrieve_time_ms'), performance_data[3])
109
118
  g.write performance_graph_full_path
110
119
  end
111
120
  end