qa_server 5.5.1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +53 -0
  4. data/app/controllers/{qa_server/authority_validation_controller.rb → concerns/qa_server/authority_validation_behavior.rb} +13 -11
  5. data/app/controllers/qa_server/authority_list_controller.rb +5 -1
  6. data/app/controllers/qa_server/check_status_controller.rb +5 -1
  7. data/app/controllers/qa_server/monitor_status_controller.rb +40 -28
  8. data/app/jobs/qa_server/monitor_tests_job.rb +50 -0
  9. data/app/models/qa_server/performance_cache.rb +11 -3
  10. data/app/models/qa_server/performance_history.rb +24 -106
  11. data/app/models/qa_server/scenario_run_history.rb +161 -176
  12. data/app/models/qa_server/scenario_run_registry.rb +4 -4
  13. data/app/prepends/prepended_linked_data/find_term.rb +4 -4
  14. data/app/prepends/prepended_linked_data/search_query.rb +4 -4
  15. data/app/prepends/prepended_rdf/rdf_graph.rb +4 -4
  16. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +23 -1
  17. data/app/presenters/qa_server/check_status_presenter.rb +4 -4
  18. data/app/presenters/qa_server/monitor_status/current_status_presenter.rb +17 -5
  19. data/app/presenters/qa_server/monitor_status/history_presenter.rb +40 -19
  20. data/app/presenters/qa_server/monitor_status/performance_presenter.rb +3 -1
  21. data/app/presenters/qa_server/monitor_status_presenter.rb +9 -9
  22. data/app/services/qa_server/monitor_cache_service.rb +22 -0
  23. data/app/services/qa_server/performance_calculator_service.rb +18 -7
  24. data/app/services/qa_server/performance_datatable_service.rb +82 -0
  25. data/app/services/qa_server/performance_graph_data_service.rb +140 -82
  26. data/app/services/qa_server/performance_graphing_service.rb +15 -12
  27. data/app/services/qa_server/time_period_service.rb +93 -0
  28. data/app/services/qa_server/time_service.rb +29 -0
  29. data/app/validators/qa_server/scenario_validator.rb +3 -3
  30. data/app/validators/qa_server/search_scenario_validator.rb +3 -3
  31. data/app/views/qa_server/monitor_status/_performance.html.erb +2 -1
  32. data/app/views/qa_server/monitor_status/_test_history.html.erb +1 -2
  33. data/app/views/qa_server/monitor_status/_test_summary.html.erb +2 -2
  34. data/config/locales/qa_server.en.yml +3 -4
  35. data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +4 -0
  36. data/lib/qa_server.rb +0 -23
  37. data/lib/qa_server/configuration.rb +20 -0
  38. data/lib/qa_server/version.rb +1 -1
  39. data/spec/lib/qa_server_spec.rb +0 -51
  40. data/spec/services/qa_server/monitor_cache_service_spec.rb +20 -0
  41. data/spec/services/qa_server/time_period_service_spec.rb +246 -0
  42. data/spec/services/qa_server/time_service_spec.rb +50 -0
  43. metadata +14 -3
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- # Provide access to the scenario_results_history database table which tracks specific scenario runs over time.
2
+ # Provide access to the scenario_run_history database table which tracks scenario runs over time.
3
3
  module QaServer
4
- class ScenarioRunHistory < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
4
+ class ScenarioRunHistory < ActiveRecord::Base
5
5
  self.table_name = 'scenario_run_history'
6
6
  belongs_to :scenario_run_registry
7
7
  enum scenario_type: [:connection, :accuracy, :performance], _suffix: :type
@@ -15,195 +15,180 @@ module QaServer
15
15
 
16
16
  self.summary_class = QaServer::ScenarioRunSummary
17
17
 
18
- # Save a scenario result
19
- # @param run_id [Integer] the run on which to gather statistics
20
- # @param result [Hash] the scenario result to be saved
21
- def self.save_result(run_id:, scenario_result:)
22
- QaServer::ScenarioRunHistory.create(scenario_run_registry_id: run_id,
23
- status: scenario_result[:status],
24
- authority_name: scenario_result[:authority_name],
25
- subauthority_name: scenario_result[:subauthority_name],
26
- service: scenario_result[:service],
27
- action: scenario_result[:action],
28
- url: scenario_result[:url],
29
- err_message: scenario_result[:err_message],
30
- run_time: scenario_result[:run_time])
31
- end
18
+ class << self
19
+ # Save a scenario result
20
+ # @param run_id [Integer] the run on which to gather statistics
21
+ # @param result [Hash] the scenario result to be saved
22
+ def save_result(run_id:, scenario_result:)
23
+ QaServer::ScenarioRunHistory.create(scenario_run_registry_id: run_id,
24
+ status: scenario_result[:status],
25
+ authority_name: scenario_result[:authority_name],
26
+ subauthority_name: scenario_result[:subauthority_name],
27
+ service: scenario_result[:service],
28
+ action: scenario_result[:action],
29
+ url: scenario_result[:url],
30
+ err_message: scenario_result[:err_message],
31
+ run_time: scenario_result[:run_time])
32
+ end
32
33
 
33
- # Get a summary of passing/failing tests for a run.
34
- # @param scenario_run [QaServer::ScenarioRunRegistry] the run on which to gather statistics
35
- # @param force [Boolean] if true, forces cache to regenerate; otherwise, returns value from cache unless expired
36
- # @returns [QaServer::ScenarioRunSummary] statistics on the requested run
37
- # @example ScenarioRunSummary includes methods for accessing
38
- # * run_id: 14,
39
- # * run_dt_stamp:
40
- # * authority_count: 22,
41
- # * failing_authority_count: 1
42
- # * passing_scenario_count: 156,
43
- # * failing_scenario_count: 3,
44
- # * total_scenario_count: 159,
45
- def self.run_summary(scenario_run:, force: false)
46
- Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do
47
- Rails.logger.info("#{self.class}##{__method__} - creating summary of latest run - cache expired or refresh requested (#{force})")
48
- status = status_counts_in_run(run_id: scenario_run.id)
49
- summary_class.new(run_id: scenario_run.id,
50
- run_dt_stamp: scenario_run.dt_stamp,
51
- authority_count: authorities_in_run(run_id: scenario_run.id).count,
52
- failing_authority_count: authorities_with_failures_in_run(run_id: scenario_run.id).count,
53
- passing_scenario_count: status['good'],
54
- failing_scenario_count: status['bad'] + status['unknown'])
34
+ # Get a summary of passing/failing tests for a run.
35
+ # @param scenario_run [QaServer::ScenarioRunRegistry] the run on which to gather statistics
36
+ # @param force [Boolean] if true, forces cache to regenerate; otherwise, returns value from cache unless expired
37
+ # @returns [QaServer::ScenarioRunSummary] statistics on the requested run
38
+ # @example ScenarioRunSummary includes methods for accessing
39
+ # * run_id: 14,
40
+ # * run_dt_stamp:
41
+ # * authority_count: 22,
42
+ # * failing_authority_count: 1
43
+ # * passing_scenario_count: 156,
44
+ # * failing_scenario_count: 3,
45
+ # * total_scenario_count: 159,
46
+ def run_summary(scenario_run:, force: false)
47
+ Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
48
+ QaServer.config.monitor_logger.info("(QaServer::ScenarioRunHistory##{__method__}) - creating summary of latest run - cache expired or refresh requested (force: #{force})")
49
+ status = status_counts_in_run(run_id: scenario_run.id)
50
+ summary_class.new(run_id: scenario_run.id,
51
+ run_dt_stamp: scenario_run.dt_stamp,
52
+ authority_count: authorities_in_run(run_id: scenario_run.id).count,
53
+ failing_authority_count: authorities_with_failures_in_run(run_id: scenario_run.id).count,
54
+ passing_scenario_count: status['good'],
55
+ failing_scenario_count: status['bad'] + status['unknown'])
56
+ end
55
57
  end
56
- end
57
58
 
58
- # Get set of all scenario results for a run.
59
- # @param run_id [Integer] the run on which to gather statistics
60
- # @param authority_name [String] limit results to those for the authority with this name
61
- # @param status [Array<Symbol> | Symbol] :good, :bad, :unknown, or any of these in an array to select multiple status
62
- # @param url [String] limit results to a specific scenario URL
63
- # @returns [Array<ScenarioRunHistory>] scenario details for all scenarios in the run
64
- # @example
65
- # [ { status: :bad,
66
- # authority_name: "geonames_ld4l_cache",
67
- # subauthority_name: "area",
68
- # service: "ld4l_cache",
69
- # action: "search",
70
- # url: "/qa/search/linked_data/geonames_ld4l_cache/area?q=France&maxRecords=4",
71
- # err_message: "Unable to connect to authority",
72
- # scenario_type: :connection
73
- # run_time: 11.2 },
74
- # { status: :good,
75
- # authority_name: "oclcfast_ld4l_cache",
76
- # subauthority_name: "Organization",
77
- # service: "ld4l_cache",
78
- # action: "search",
79
- # url: "/qa/search/linked_data/oclcfast_ld4l_cache/organization?q=mark twain&maxRecords=4",
80
- # err_message: "",
81
- # scenario_type: :connection
82
- # run_time: 0.131 },
83
- # { status: :unknown,
84
- # authority_name: "oclcfast_ld4l_cache",
85
- # subauthority_name: "Person",
86
- # service: "ld4l_cache",
87
- # action: "search",
88
- # url: "/qa/search/linked_data/oclcfast_ld4l_cache/person?q=mark twain&maxRecords=4",
89
- # err_message: "Not enough search results returned",
90
- # scenario_type: :connection
91
- # run_time: 0.123 } ]
92
- # @deprecated Not used anywhere. Being removed.
93
- def self.run_results(run_id:, authority_name: nil, status: nil, url: nil)
94
- return [] unless run_id
95
- where = {}
96
- where[:scenario_run_registry_id] = run_id
97
- where[:authority_name] = authority_name if authority_name.present?
98
- where[:status] = status if status.present?
99
- where[:url] = url if url.present?
100
- QaServer::ScenarioRunHistory.where(where).to_a
101
- end
102
- deprecation_deprecate run_results: "Not used anywhere. Being removed."
59
+ # Get set of all scenario results for a run.
60
+ # @param run_id [Integer] the run on which to gather statistics
61
+ # @param authority_name [String] limit results to those for the authority with this name
62
+ # @param status [Array<Symbol> | Symbol] :good, :bad, :unknown, or any of these in an array to select multiple status
63
+ # @param url [String] limit results to a specific scenario URL
64
+ # @returns [Array<ScenarioRunHistory>] scenario details for all scenarios in the run
65
+ # @example
66
+ # [ { status: :bad,
67
+ # authority_name: "geonames_ld4l_cache",
68
+ # subauthority_name: "area",
69
+ # service: "ld4l_cache",
70
+ # action: "search",
71
+ # url: "/qa/search/linked_data/geonames_ld4l_cache/area?q=France&maxRecords=4",
72
+ # err_message: "Unable to connect to authority",
73
+ # scenario_type: :connection
74
+ # run_time: 11.2 },
75
+ # { status: :good,
76
+ # authority_name: "oclcfast_ld4l_cache",
77
+ # subauthority_name: "Organization",
78
+ # service: "ld4l_cache",
79
+ # action: "search",
80
+ # url: "/qa/search/linked_data/oclcfast_ld4l_cache/organization?q=mark twain&maxRecords=4",
81
+ # err_message: "",
82
+ # scenario_type: :connection
83
+ # run_time: 0.131 },
84
+ # { status: :unknown,
85
+ # authority_name: "oclcfast_ld4l_cache",
86
+ # subauthority_name: "Person",
87
+ # service: "ld4l_cache",
88
+ # action: "search",
89
+ # url: "/qa/search/linked_data/oclcfast_ld4l_cache/person?q=mark twain&maxRecords=4",
90
+ # err_message: "Not enough search results returned",
91
+ # scenario_type: :connection
92
+ # run_time: 0.123 } ]
93
+ # @deprecated Not used anywhere. Being removed.
94
+ def run_results(run_id:, authority_name: nil, status: nil, url: nil)
95
+ return [] unless run_id
96
+ where = {}
97
+ where[:scenario_run_registry_id] = run_id
98
+ where[:authority_name] = authority_name if authority_name.present?
99
+ where[:status] = status if status.present?
100
+ where[:url] = url if url.present?
101
+ QaServer::ScenarioRunHistory.where(where).to_a
102
+ end
103
+ deprecation_deprecate run_results: "Not used anywhere. Being removed."
103
104
 
104
- # Get set of failures for a run, if any.
105
- # @param run_id [Integer] the run on which to gather statistics
106
- # @param force [Boolean] if true, forces cache to regenerate; otherwise, returns value from cache unless expired
107
- # @returns [Array<Hash>] scenario details for any failing scenarios in the run
108
- # @example
109
- # [ { status: :bad,
110
- # authority_name: "geonames_ld4l_cache",
111
- # subauthority_name: "area",
112
- # service: "ld4l_cache",
113
- # action: "search",
114
- # url: "/qa/search/linked_data/geonames_ld4l_cache/area?q=France&maxRecords=4",
115
- # err_message: "Unable to connect to authority",
116
- # scenario_type: :connection
117
- # run_time: 11.2 },
118
- # { status: :unknown,
119
- # authority_name: "oclcfast_ld4l_cache",
120
- # subauthority_name: "Person",
121
- # service: "ld4l_cache",
122
- # action: "search",
123
- # url: "/qa/search/linked_data/oclcfast_ld4l_cache/person?q=mark twain&maxRecords=4",
124
- # err_message: "Not enough search results returned",
125
- # scenario_type: :connection
126
- # run_time: 0.123 } ]
127
- def self.run_failures(run_id:, force: false)
128
- return [] unless run_id
129
- Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do
130
- Rails.logger.info("#{self.class}##{__method__} - finding failures in latest run - cache expired or refresh requested (#{force})")
131
- QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: :good).to_a
105
+ # Get set of failures for a run, if any.
106
+ # @param run_id [Integer] the run on which to gather statistics
107
+ # @param force [Boolean] if true, forces cache to regenerate; otherwise, returns value from cache unless expired
108
+ # @returns [Array<Hash>] scenario details for any failing scenarios in the run
109
+ # @example
110
+ # [ { status: :bad,
111
+ # authority_name: "geonames_ld4l_cache",
112
+ # subauthority_name: "area",
113
+ # service: "ld4l_cache",
114
+ # action: "search",
115
+ # url: "/qa/search/linked_data/geonames_ld4l_cache/area?q=France&maxRecords=4",
116
+ # err_message: "Unable to connect to authority",
117
+ # scenario_type: :connection
118
+ # run_time: 11.2 },
119
+ # { status: :unknown,
120
+ # authority_name: "oclcfast_ld4l_cache",
121
+ # subauthority_name: "Person",
122
+ # service: "ld4l_cache",
123
+ # action: "search",
124
+ # url: "/qa/search/linked_data/oclcfast_ld4l_cache/person?q=mark twain&maxRecords=4",
125
+ # err_message: "Not enough search results returned",
126
+ # scenario_type: :connection
127
+ # run_time: 0.123 } ]
128
+ def run_failures(run_id:, force: false)
129
+ return [] unless run_id
130
+ Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
131
+ QaServer.config.monitor_logger.info("(QaServer::ScenarioRunHistory##{__method__}) - finding failures in latest run - cache expired or refresh requested (force: #{force})")
132
+ QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: :good).to_a
133
+ end
132
134
  end
133
- end
134
135
 
135
- # Get a summary level of historical data
136
- # @returns [Array<Array>] summary of passing/failing tests for each authority
137
- # @example [auth_name, failing, passing]
138
- # [ [ 'agrovoc', 0, 24 ],
139
- # [ 'geonames_ld4l_cache', 2, 22 ] ... ]
140
- def self.historical_summary(force: false)
141
- Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour, force: force) do
142
- Rails.logger.info("#{self.class}##{__method__} - calculating pass/fail per authority across all time - cache expired or refresh requested (#{force})")
143
- runs = all_runs_per_authority
144
- failures = failing_runs_per_authority
145
- return [] unless runs.present?
146
- data = []
147
- runs.each do |auth_name, run_count|
148
- data << pass_fail_stats_for_authority(failures, auth_name, run_count)
136
+ # Get a summary level of historical data
137
+ # @returns [Array<Array>] summary of passing/failing tests for each authority
138
+ # @example [auth_name, failing, passing]
139
+ # { 'agrovoc' => { "good" => 0, "bad" => 24 },
140
+ # 'geonames_ld4l_cache' => { "good" => 2, "bad" => 22 } }
141
+ def historical_summary(force: false)
142
+ Rails.cache.fetch("QaServer::ScenarioRunHistory/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 1.minute, force: force) do
143
+ runs_per_authority_for_time_period
149
144
  end
150
- data
151
145
  end
152
- end
153
146
 
154
- def self.pass_fail_stats_for_authority(failures, auth_name, run_count)
155
- auth_data = []
156
- auth_data[0] = auth_name
157
- failure_count = failures.key?(auth_name) ? failures[auth_name] : 0
158
- auth_data[1] = failure_count
159
- auth_data[2] = run_count - failure_count # passing
160
- auth_data
161
- end
162
- private_class_method :pass_fail_stats_for_authority
147
+ private
163
148
 
164
- def self.authorities_in_run(run_id:)
165
- QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).pluck(:authority_name).uniq
166
- end
167
- private_class_method :authorities_in_run
149
+ def authorities_in_run(run_id:)
150
+ QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).pluck(:authority_name).uniq
151
+ end
168
152
 
169
- def self.authorities_with_failures_in_run(run_id:)
170
- QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: 'good').pluck('authority_name').uniq
171
- end
172
- private_class_method :authorities_with_failures_in_run
153
+ def authorities_with_failures_in_run(run_id:)
154
+ QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: 'good').pluck('authority_name').uniq
155
+ end
173
156
 
174
- # @return [Hash] status counts across all authorities (used for current test summary)
175
- # @example { "good" => 23, "bad" => 3, "unknown" => 0 }
176
- def self.status_counts_in_run(run_id:)
177
- status = QaServer::ScenarioRunHistory.group('status').where(scenario_run_registry_id: run_id).count
178
- status["good"] = 0 unless status.key? "good"
179
- status["bad"] = 0 unless status.key? "bad"
180
- status["unknown"] = 0 unless status.key? "unknown"
181
- status
182
- end
183
- private_class_method :status_counts_in_run
157
+ # @return [Hash] status counts across all authorities (used for current test summary)
158
+ # @example { "good" => 23, "bad" => 3, "unknown" => 0 }
159
+ def status_counts_in_run(run_id:)
160
+ status = QaServer::ScenarioRunHistory.group('status').where(scenario_run_registry_id: run_id).count
161
+ status["good"] = 0 unless status.key? "good"
162
+ status["bad"] = 0 unless status.key? "bad"
163
+ status["unknown"] = 0 unless status.key? "unknown"
164
+ status
165
+ end
184
166
 
185
- def self.all_runs_per_authority
186
- # TODO: Really want to only get one run per day. Preferably the first run of the day.
187
- authority_runs = QaServer::ScenarioRunHistory.pluck(:authority_name, :scenario_run_registry_id).uniq # rubocop:disable Rails/UniqBeforePluck
188
- runs_per_authority(authority_runs)
189
- end
190
- private_class_method :all_runs_per_authority
167
+ def runs_per_authority_for_time_period
168
+ status = QaServer::ScenarioRunHistory.joins(:scenario_run_registry).where(time_period_where).group('authority_name', 'status').count
169
+ status.each_with_object({}) do |(k, v), hash|
170
+ h = hash[k[0]] || { "good" => 0, "bad" => 0 } # initialize for an authority if it doesn't already exist
171
+ h[k[1]] = v
172
+ hash[k[0]] = h
173
+ end
174
+ end
191
175
 
192
- def self.failing_runs_per_authority
193
- failing_authority_runs = QaServer::ScenarioRunHistory.where.not(status: 'good').pluck(:authority_name, :scenario_run_registry_id).uniq
194
- runs_per_authority(failing_authority_runs)
195
- end
196
- private_class_method :failing_runs_per_authority
176
+ def expected_time_period
177
+ QaServer.config.historical_datatable_default_time_period
178
+ end
197
179
 
198
- def self.runs_per_authority(authority_runs)
199
- runs_per_authority = {}
200
- authority_runs.each do |auth_run|
201
- auth_name = auth_run[0]
202
- runs_per_authority[auth_name] = 0 unless runs_per_authority.key? auth_name
203
- runs_per_authority[auth_name] += 1
204
- end
205
- runs_per_authority
180
+ def time_period_where
181
+ case expected_time_period
182
+ when :day
183
+ QaServer::TimePeriodService.where_clause_for_last_24_hours(dt_table: :scenario_run_registry)
184
+ when :month
185
+ QaServer::TimePeriodService.where_clause_for_last_30_days(dt_table: :scenario_run_registry)
186
+ when :year
187
+ QaServer::TimePeriodService.where_clause_for_last_12_months(dt_table: :scenario_run_registry)
188
+ else
189
+ all_records
190
+ end
191
+ end
206
192
  end
207
- private_class_method :runs_per_authority
208
193
  end
209
194
  end
@@ -23,17 +23,17 @@ module QaServer
23
23
  end
24
24
  deprecation_deprecate latest_run_id: "Not used anywhere. Being removed."
25
25
 
26
- # @return [String] datetime stamp of first registered run
26
+ # @return [ActiveSupport::TimeWithZone] datetime stamp of first registered run
27
27
  def self.first_run_dt
28
- Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer.cache_expiry, race_condition_ttl: 1.hour) do
29
- QaServer::ScenarioRunRegistry.first.dt_stamp.in_time_zone("Eastern Time (US & Canada)").strftime("%m/%d/%y - %I:%M %p")
28
+ Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer::MonitorCacheService.cache_expiry, race_condition_ttl: 30.seconds) do
29
+ QaServer::ScenarioRunRegistry.first.dt_stamp
30
30
  end
31
31
  end
32
32
 
33
33
  # Register and save latest test run results
34
34
  # @param scenarios_results [Array<Hash>] results of latest test run
35
35
  def self.save_run(scenarios_results:)
36
- run = QaServer::ScenarioRunRegistry.create(dt_stamp: QaServer.current_time)
36
+ run = QaServer::ScenarioRunRegistry.create(dt_stamp: QaServer::TimeService.current_time)
37
37
  scenarios_results.each { |result| QaServer::ScenarioRunHistory.save_result(run_id: run.id, scenario_result: result) }
38
38
  end
39
39
  end
@@ -21,7 +21,7 @@ module PrependedLinkedData::FindTerm
21
21
 
22
22
  def setup_find(request_header: {}, language: nil, replacements: {}, subauth: nil, format: nil, performance_data: false) # rubocop:disable Metrics/ParameterLists
23
23
  QaServer.log_agent_info(request_header[:request])
24
- @start_time_s = QaServer.current_time_s
24
+ @start_time_s = QaServer::TimeService.current_time_s
25
25
  request_header = build_request_header(language: language, replacements: replacements, subauth: subauth, format: format, performance_data: performance_data) if request_header.empty?
26
26
  @saved_performance_data = performance_data || request_header[:performance_data]
27
27
  request_header[:performance_data] = true
@@ -30,7 +30,7 @@ module PrependedLinkedData::FindTerm
30
30
 
31
31
  def update_performance_history_record(full_results)
32
32
  return QaServer.config.performance_cache.destroy(@phid) unless full_results.is_a?(Hash) && full_results.key?(:performance)
33
- updates = { action_time_ms: (QaServer.current_time_s - @start_time_s) * 1000,
33
+ updates = { action_time_ms: (QaServer::TimeService.current_time_s - @start_time_s) * 1000,
34
34
  size_bytes: full_results[:performance][:fetched_bytes],
35
35
  retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
36
36
  normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
@@ -42,12 +42,12 @@ module PrependedLinkedData::FindTerm
42
42
  def load_graph(url:)
43
43
  return super if QaServer.config.suppress_performance_gathering
44
44
 
45
- access_start_dt = QaServer.current_time
45
+ access_start_dt = QaServer::TimeService.current_time
46
46
 
47
47
  url += "&phid=#{@phid}"
48
48
  @full_graph = graph_service.load_graph(url: url)
49
49
 
50
- access_end_dt = QaServer.current_time
50
+ access_end_dt = QaServer::TimeService.current_time
51
51
  @access_time_s = access_end_dt - access_start_dt
52
52
  @fetched_size = full_graph.triples.to_s.size if performance_data?
53
53
  Rails.logger.info("Time to receive data from authority: #{access_time_s}s")
@@ -21,7 +21,7 @@ module PrependedLinkedData::SearchQuery
21
21
 
22
22
  def setup_search(request_header: {}, language: nil, replacements: {}, subauth: nil, context: false, performance_data: false) # rubocop:disable Metrics/ParameterLists
23
23
  QaServer.log_agent_info(request_header[:request])
24
- @start_time_s = QaServer.current_time_s
24
+ @start_time_s = QaServer::TimeService.current_time_s
25
25
  request_header = build_request_header(language: language, replacements: replacements, subauth: subauth, context: context, performance_data: performance_data) if request_header.empty?
26
26
  @saved_performance_data = performance_data || request_header[:performance_data]
27
27
  request_header[:performance_data] = true
@@ -30,7 +30,7 @@ module PrependedLinkedData::SearchQuery
30
30
 
31
31
  def update_performance_history_record(full_results)
32
32
  return QaServer.config.performance_cache.destroy(@phid) unless full_results.is_a?(Hash) && full_results.key?(:performance)
33
- updates = { action_time_ms: (QaServer.current_time_s - @start_time_s) * 1000,
33
+ updates = { action_time_ms: (QaServer::TimeService.current_time_s - @start_time_s) * 1000,
34
34
  size_bytes: full_results[:performance][:fetched_bytes],
35
35
  retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
36
36
  normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
@@ -42,12 +42,12 @@ module PrependedLinkedData::SearchQuery
42
42
  def load_graph(url:)
43
43
  return super if QaServer.config.suppress_performance_gathering
44
44
 
45
- access_start_dt = QaServer.current_time
45
+ access_start_dt = QaServer::TimeService.current_time
46
46
 
47
47
  url += "&phid=#{@phid}"
48
48
  @full_graph = graph_service.load_graph(url: url)
49
49
 
50
- access_end_dt = QaServer.current_time
50
+ access_end_dt = QaServer::TimeService.current_time
51
51
  @access_time_s = access_end_dt - access_start_dt
52
52
  @fetched_size = full_graph.triples.to_s.size if performance_data?
53
53
  Rails.logger.info("Time to receive data from authority: #{access_time_s}s")