qa_server 7.3.0 → 7.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop_fixme.yml +3 -0
  3. data/.travis.yml +4 -5
  4. data/CHANGELOG.md +45 -0
  5. data/Rakefile +1 -1
  6. data/app/assets/stylesheets/qa_server/_check-status.scss +36 -0
  7. data/app/cache_processors/qa_server/cache_expiry_service.rb +8 -8
  8. data/app/cache_processors/qa_server/job_id_cache.rb +4 -4
  9. data/app/cache_processors/qa_server/performance_cache.rb +34 -34
  10. data/app/cache_processors/qa_server/performance_day_graph_cache.rb +7 -7
  11. data/app/cache_processors/qa_server/performance_month_graph_cache.rb +7 -7
  12. data/app/cache_processors/qa_server/performance_year_graph_cache.rb +7 -7
  13. data/app/cache_processors/qa_server/scenario_history_cache.rb +7 -7
  14. data/app/cache_processors/qa_server/scenario_history_graph_cache.rb +7 -7
  15. data/app/cache_processors/qa_server/scenario_run_cache.rb +7 -7
  16. data/app/cache_processors/qa_server/scenario_run_failures_cache.rb +7 -7
  17. data/app/cache_processors/qa_server/scenario_run_summary_cache.rb +7 -7
  18. data/app/controllers/concerns/qa_server/authority_validation_behavior.rb +49 -44
  19. data/app/controllers/qa_server/check_status_controller.rb +92 -22
  20. data/app/controllers/qa_server/fetch_controller.rb +36 -36
  21. data/app/controllers/qa_server/monitor_status_controller.rb +106 -84
  22. data/app/jobs/qa_server/history_graph_job.rb +10 -10
  23. data/app/jobs/qa_server/monitor_tests_job.rb +17 -17
  24. data/app/jobs/qa_server/performance_day_graph_job.rb +21 -21
  25. data/app/jobs/qa_server/performance_month_graph_job.rb +21 -21
  26. data/app/jobs/qa_server/performance_per_byte_job.rb +85 -0
  27. data/app/jobs/qa_server/performance_year_graph_job.rb +21 -21
  28. data/app/loggers/qa_server/scenario_logger.rb +74 -4
  29. data/app/models/concerns/qa_server/performance_history_data_keys.rb +8 -0
  30. data/app/models/qa_server/authority_scenario.rb +4 -4
  31. data/app/models/qa_server/authority_status.rb +2 -2
  32. data/app/models/qa_server/authority_status_failure.rb +1 -1
  33. data/app/models/qa_server/performance_history.rb +2 -2
  34. data/app/models/qa_server/scenario_run_history.rb +63 -54
  35. data/app/models/qa_server/scenario_run_registry.rb +2 -2
  36. data/app/models/qa_server/scenarios.rb +26 -26
  37. data/app/models/qa_server/search_scenario.rb +24 -13
  38. data/app/models/qa_server/term_scenario.rb +29 -29
  39. data/app/prepends/prepended_linked_data/find_term.rb +40 -40
  40. data/app/prepends/prepended_linked_data/search_query.rb +36 -36
  41. data/app/prepends/prepended_rdf/rdf_graph.rb +7 -7
  42. data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +32 -32
  43. data/app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb +64 -64
  44. data/app/presenters/qa_server/check_status_presenter.rb +63 -7
  45. data/app/presenters/qa_server/monitor_status/current_status_presenter.rb +9 -8
  46. data/app/presenters/qa_server/monitor_status/history_presenter.rb +5 -2
  47. data/app/services/concerns/qa_server/gruff_graph.rb +16 -16
  48. data/app/services/qa_server/authority_loader_service.rb +14 -14
  49. data/app/services/qa_server/authority_validator_service.rb +1 -0
  50. data/app/services/qa_server/database_migrator.rb +14 -14
  51. data/app/services/qa_server/history_graphing_service.rb +30 -30
  52. data/app/services/qa_server/performance_calculator_service.rb +80 -80
  53. data/app/services/qa_server/performance_datatable_service.rb +35 -35
  54. data/app/services/qa_server/performance_graph_data_service.rb +27 -27
  55. data/app/services/qa_server/performance_graphing_service.rb +55 -55
  56. data/app/services/qa_server/performance_per_byte_calculator_service.rb +88 -0
  57. data/app/services/qa_server/performance_per_byte_data_service.rb +41 -0
  58. data/app/services/qa_server/scenarios_loader_service.rb +1 -1
  59. data/app/services/qa_server/time_period_service.rb +21 -21
  60. data/app/validators/qa_server/scenario_validator.rb +99 -87
  61. data/app/validators/qa_server/search_scenario_validator.rb +67 -61
  62. data/app/validators/qa_server/term_scenario_validator.rb +20 -15
  63. data/app/views/qa_server/check_status/index.html.erb +120 -24
  64. data/app/views/qa_server/monitor_status/_test_summary.html.erb +1 -1
  65. data/config/i18n-tasks.yml +133 -0
  66. data/config/locales/qa_server.en.yml +21 -5
  67. data/lib/generators/qa_server/assets_generator.rb +4 -4
  68. data/lib/generators/qa_server/templates/config/authorities/linked_data/cerl_ld4l_cache.json +2 -2
  69. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json +62 -1
  70. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +45 -11
  71. data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_ulan_ld4l_cache.json +104 -8
  72. data/lib/generators/qa_server/templates/config/authorities/linked_data/isni_ld4l_cache.json +90 -0
  73. data/lib/generators/qa_server/templates/config/authorities/linked_data/ligatus_ld4l_cache.json +133 -0
  74. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +248 -0
  75. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +248 -0
  76. data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo_ld4l_cache.json +4 -4
  77. data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +117 -0
  78. data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +135 -3
  79. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +5 -0
  80. data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +2 -4
  81. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_direct_validation.yml +31 -0
  82. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_ld4l_cache_validation.yml +31 -0
  83. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +24 -12
  84. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/dbpedia_ld4l_cache_validation.yml +33 -0
  85. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_direct_validation.yml +35 -0
  86. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +55 -5
  87. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +253 -0
  88. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +31 -1
  89. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +38 -1
  90. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/isni_ld4l_cache_validation.yml +10 -0
  91. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/ligatus_ld4l_cache_validation.yml +36 -0
  92. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +69 -44
  93. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +22 -0
  94. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +65 -0
  95. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo2_ld4l_cache_validation.yml +78 -0
  96. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo3_ld4l_cache_validation.yml +73 -0
  97. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +71 -3
  98. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml +6 -0
  99. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +30 -0
  100. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +430 -0
  101. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +54 -1
  102. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_ld4l_cache_validation.yml +37 -0
  103. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclc_fast_validation.yml +71 -5
  104. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +73 -2
  105. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +73 -0
  106. data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +307 -0
  107. data/lib/qa_server/configuration.rb +28 -24
  108. data/lib/qa_server/version.rb +1 -1
  109. data/qa_server.gemspec +6 -5
  110. data/spec/feature/accuracy_spec.rb +32 -0
  111. data/spec/i18n_spec.rb +35 -0
  112. data/spec/spec_helper.rb +4 -0
  113. metadata +66 -17
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # Provide access to the authority_status database table which tracks a summary of status data over time.
3
3
  module QaServer
4
- class AuthorityStatus < ActiveRecord::Base
4
+ class AuthorityStatus < ApplicationRecord
5
5
  self.table_name = 'authority_status'
6
- has_many :authority_status_failure, foreign_key: :authority_status_id
6
+ has_many :authority_status_failure, dependent: :destroy
7
7
 
8
8
  # Get the latest saved status.
9
9
  def self.latest
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  # Provide access to the authority_status_failure database table which tracks specific failures over time.
3
3
  module QaServer
4
- class AuthorityStatusFailure < ActiveRecord::Base
4
+ class AuthorityStatusFailure < ApplicationRecord
5
5
  self.table_name = 'authority_status_failure'
6
6
  belongs_to :authority_status
7
7
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
  # Provide access to the scenario_results_history database table which tracks specific scenario runs over time.
3
3
  module QaServer
4
- class PerformanceHistory < ActiveRecord::Base
4
+ class PerformanceHistory < ApplicationRecord
5
5
  self.table_name = 'performance_history'
6
6
 
7
- enum action: [:fetch, :search]
7
+ enum action: { fetch: 0, search: 1 }
8
8
 
9
9
  class_attribute :datatable_data_service_class, :graph_data_service_class
10
10
  self.datatable_data_service_class = QaServer::PerformanceDatatableService
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
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
4
+ class ScenarioRunHistory < ApplicationRecord # rubocop:disable Metrics/ClassLength
5
5
  self.table_name = 'scenario_run_history'
6
6
  belongs_to :scenario_run_registry
7
- enum scenario_type: [:connection, :accuracy, :performance], _suffix: :type
8
- enum status: [:good, :bad, :unknown], _suffix: true
7
+ enum scenario_type: { connection: 0, accuracy: 1, performance: 2 }, _suffix: :type
8
+ enum status: { good: 0, bad: 1, unknown: 2 }, _suffix: true
9
9
 
10
10
  GOOD_MARKER = '√'
11
11
  BAD_MARKER = 'X'
12
12
  UNKNOWN_MARKER = '?'
13
13
 
14
- class_attribute :summary_class
15
-
14
+ class_attribute :summary_class, :authority_lister_class
16
15
  self.summary_class = QaServer::ScenarioRunSummary
16
+ self.authority_lister_class = QaServer::AuthorityListerService
17
17
 
18
18
  class << self
19
19
  # Save a scenario result
@@ -92,70 +92,79 @@ module QaServer
92
92
  days_unknown = count_days(:unknown)
93
93
  keys = (days_good.keys + days_bad.keys + days_unknown.keys).uniq.sort
94
94
  keys.each_with_object({}) do |auth, hash|
95
+ next unless active_authority? auth
95
96
  hash[auth] = { good: day_count(auth, days_good), bad: day_count(auth, days_bad) + day_count(auth, days_unknown) }
96
97
  end
97
98
  end
98
99
 
99
- private
100
+ private
100
101
 
101
- def day_count(auth, days)
102
- days&.key?(auth) ? days[auth] : 0
103
- end
102
+ def active_authority?(auth)
103
+ active_authorities.include? auth.to_sym
104
+ end
104
105
 
105
- def count_days(status)
106
- where = time_period_where
107
- where[:status] = status
108
- auths = QaServer::ScenarioRunHistory.where(where).select("authority_name").group("date, authority_name")
109
- .order("authority_name").pluck(:authority_name)
110
- auths.each_with_object({}) do |auth, hash|
111
- hash[auth] = 0 unless hash.key? auth
112
- hash[auth] += 1
113
- end
114
- end
106
+ def active_authorities
107
+ @active_authorities = authority_lister_class.authorities_list
108
+ end
115
109
 
116
- def authorities_in_run(run_id:)
117
- QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).pluck(:authority_name).uniq
118
- end
110
+ def day_count(auth, days)
111
+ days&.key?(auth) ? days[auth] : 0
112
+ end
119
113
 
120
- def authorities_with_failures_in_run(run_id:)
121
- QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: 'good').pluck('authority_name').uniq
114
+ def count_days(status)
115
+ where = time_period_where
116
+ where[:status] = status
117
+ auths = QaServer::ScenarioRunHistory.where(where).select("authority_name").group("date, authority_name")
118
+ .order("authority_name").pluck(:authority_name)
119
+ auths.each_with_object({}) do |auth, hash|
120
+ hash[auth] = 0 unless hash.key? auth
121
+ hash[auth] += 1
122
122
  end
123
+ end
123
124
 
124
- # @return [Hash] status counts across all authorities (used for current test summary)
125
- # @example { "good" => 23, "bad" => 3, "unknown" => 0 }
126
- def status_counts_in_run(run_id:)
127
- status = QaServer::ScenarioRunHistory.group('status').where(scenario_run_registry_id: run_id).count
128
- status["good"] = 0 unless status.key? "good"
129
- status["bad"] = 0 unless status.key? "bad"
130
- status["unknown"] = 0 unless status.key? "unknown"
131
- status
132
- end
125
+ def authorities_in_run(run_id:)
126
+ QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).pluck(:authority_name).uniq
127
+ end
133
128
 
134
- def runs_per_authority_for_time_period
135
- status = QaServer::ScenarioRunHistory.joins(:scenario_run_registry).where(time_period_where).group('authority_name', 'status').count
136
- status.each_with_object({}) do |(k, v), hash|
137
- h = hash[k[0]] || { "good" => 0, "bad" => 0 } # initialize for an authority if it doesn't already exist
138
- h[k[1]] = v
139
- hash[k[0]] = h
140
- end
141
- end
129
+ def authorities_with_failures_in_run(run_id:)
130
+ QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).where.not(status: 'good').pluck('authority_name').uniq
131
+ end
132
+
133
+ # @return [Hash] status counts across all authorities (used for current test summary)
134
+ # @example { "good" => 23, "bad" => 3, "unknown" => 0 }
135
+ def status_counts_in_run(run_id:)
136
+ status = QaServer::ScenarioRunHistory.group('status').where(scenario_run_registry_id: run_id).count
137
+ status["good"] = 0 unless status.key? "good"
138
+ status["bad"] = 0 unless status.key? "bad"
139
+ status["unknown"] = 0 unless status.key? "unknown"
140
+ status
141
+ end
142
142
 
143
- def expected_time_period
144
- QaServer.config.historical_datatable_default_time_period
143
+ def runs_per_authority_for_time_period
144
+ status = QaServer::ScenarioRunHistory.joins(:scenario_run_registry).where(time_period_where).group('authority_name', 'status').count
145
+ status.each_with_object({}) do |(k, v), hash|
146
+ h = hash[k[0]] || { "good" => 0, "bad" => 0 } # initialize for an authority if it doesn't already exist
147
+ h[k[1]] = v
148
+ hash[k[0]] = h
145
149
  end
150
+ end
151
+
152
+ def expected_time_period
153
+ QaServer.config.historical_datatable_default_time_period
154
+ end
146
155
 
147
- def time_period_where
148
- case expected_time_period
149
- when :day
150
- QaServer::TimePeriodService.where_clause_for_last_24_hours(dt_table: :scenario_run_history, dt_column: :date)
151
- when :month
152
- QaServer::TimePeriodService.where_clause_for_last_30_days(dt_table: :scenario_run_history, dt_column: :date)
153
- when :year
154
- QaServer::TimePeriodService.where_clause_for_last_12_months(dt_table: :scenario_run_history, dt_column: :date)
155
- else
156
- all_records
157
- end
156
+ def time_period_where
157
+ case expected_time_period
158
+ when :day
159
+ QaServer::TimePeriodService.where_clause_for_last_24_hours(dt_table: :scenario_run_history, dt_column: :date)
160
+ when :month
161
+ QaServer::TimePeriodService.where_clause_for_last_30_days(dt_table: :scenario_run_history, dt_column: :date)
162
+ when :year
163
+ QaServer::TimePeriodService.where_clause_for_last_12_months(dt_table: :scenario_run_history, dt_column: :date)
164
+ else
165
+ all_records
158
166
  end
167
+ end
159
168
  end
160
169
  end
161
170
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  # Provide access to the scenario_run_registry database table which registers each run of tests made over time.
3
3
  module QaServer
4
- class ScenarioRunRegistry < ActiveRecord::Base
4
+ class ScenarioRunRegistry < ApplicationRecord
5
5
  self.table_name = 'scenario_run_registry'
6
- has_many :scenario_run_history, foreign_key: :scenario_run_registry_id
6
+ has_many :scenario_run_history, dependent: :destroy
7
7
 
8
8
  # @return [ScenarioRunRegistry] registry data for latest run (e.g. id, dt_stamp)
9
9
  def self.latest_run
@@ -32,38 +32,38 @@ module QaServer
32
32
  parse_search_scenarios
33
33
  end
34
34
 
35
- private
35
+ private
36
36
 
37
- def parse_term_scenarios
38
- @term_scenarios = []
39
- term_scenarios_config.each do |term_scenario_config|
40
- @term_scenarios << QaServer::TermScenario.new(authority: authority,
41
- authority_name: authority_name,
42
- authority_scenario_config: authority_scenario_config,
43
- scenario_config: term_scenario_config)
44
- end
37
+ def parse_term_scenarios
38
+ @term_scenarios = []
39
+ term_scenarios_config.each do |term_scenario_config|
40
+ @term_scenarios << QaServer::TermScenario.new(authority: authority,
41
+ authority_name: authority_name,
42
+ authority_scenario_config: authority_scenario_config,
43
+ scenario_config: term_scenario_config)
45
44
  end
45
+ end
46
46
 
47
- def parse_search_scenarios
48
- @search_scenarios = []
49
- search_scenarios_config.each do |search_scenario_config|
50
- @search_scenarios << QaServer::SearchScenario.new(authority: authority,
51
- authority_name: authority_name,
52
- authority_scenario_config: authority_scenario_config,
53
- scenario_config: search_scenario_config)
54
- end
47
+ def parse_search_scenarios
48
+ @search_scenarios = []
49
+ search_scenarios_config.each do |search_scenario_config|
50
+ @search_scenarios << QaServer::SearchScenario.new(authority: authority,
51
+ authority_name: authority_name,
52
+ authority_scenario_config: authority_scenario_config,
53
+ scenario_config: search_scenario_config)
55
54
  end
55
+ end
56
56
 
57
- def authority_scenario_config
58
- scenarios_config[AUTHORITY_SCENARIO]
59
- end
57
+ def authority_scenario_config
58
+ scenarios_config[AUTHORITY_SCENARIO]
59
+ end
60
60
 
61
- def term_scenarios_config
62
- scenarios_config[TERM_SCENARIOS] || []
63
- end
61
+ def term_scenarios_config
62
+ scenarios_config[TERM_SCENARIOS] || []
63
+ end
64
64
 
65
- def search_scenarios_config
66
- scenarios_config[SEARCH_SCENARIOS] || []
67
- end
65
+ def search_scenarios_config
66
+ scenarios_config[SEARCH_SCENARIOS] || []
67
+ end
68
68
  end
69
69
  end
@@ -20,10 +20,10 @@ module QaServer
20
20
  DEFAULT_SUBJECT_URI = nil
21
21
 
22
22
  # @param authority [Qa::Authorities::LinkedData::GenericAuthority] the instance of the QA authority
23
- # @param authoity_name [Symbol] the name of the authority the scenario tests (e.g. :AGROVOC_DIRECT)
23
+ # @param authority_name [Symbol] the name of the authority the scenario tests (e.g. :AGROVOC_DIRECT)
24
24
  # @param authority_scenario_config [Hash] configurations from the yml file that pertain to all scenarios regardless of type
25
25
  # @param scenario_config [Hash] configuration from the yml file that are specific to a search scenario
26
- def initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:)
26
+ def initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) # rubocop:disable Metrics/CyclomaticComplexity
27
27
  super
28
28
  @query = scenario_config['query']
29
29
  @subauthority_name = scenario_config['subauth'] || DEFAULT_SUBAUTH
@@ -31,6 +31,7 @@ module QaServer
31
31
  @replacements = scenario_config['replacements'] || DEFAULT_REPLACEMENTS
32
32
  @expected_by_position = scenario_config['position'] || DEFAULT_POSITION
33
33
  @subject_uri = scenario_config['subject_uri'] || DEFAULT_SUBJECT_URI
34
+ @pending = scenario_config['pending'] || false
34
35
  end
35
36
 
36
37
  # Generate an example URL that can be called in a browser or through curl
@@ -42,18 +43,28 @@ module QaServer
42
43
  "#{prefix}?q=#{query}#{url_replacements}#{context}"
43
44
  end
44
45
 
45
- private
46
+ def pending?
47
+ @pending
48
+ end
49
+
50
+ private
46
51
 
47
- # Convert replacements hash into URL parameters
48
- def url_replacements
49
- return "&maxRecords=#{MAX_RECORDS}" unless replacements
50
- param_replacements = ""
51
- replacements.each { |k, v| param_replacements += "&#{k}=#{v}" }
52
- param_replacements
53
- end
52
+ # Convert replacements hash into URL parameters
53
+ def url_replacements
54
+ return "&maxRecords=#{MAX_RECORDS}" unless replacements
55
+ param_replacements = ""
56
+ replacements.each { |k, v| param_replacements += "&#{k}=#{v}" }
57
+ param_replacements
58
+ end
54
59
 
55
- def subauthority?
56
- subauthority_name.present?
57
- end
60
+ def subauthority?
61
+ subauthority_name.present?
62
+ end
63
+
64
+ def context?
65
+ # don't include context for accuracy tests
66
+ return false if expected_by_position.present?
67
+ super
68
+ end
58
69
  end
59
70
  end
@@ -26,41 +26,41 @@ module QaServer
26
26
  authority.term_id_expects_uri? ? fetch_url : show_url
27
27
  end
28
28
 
29
- private
29
+ private
30
30
 
31
- # Generate an example URL that can be called in a browser or through curl
32
- # @return [String] the example URL
33
- def show_url
34
- "#{prefix_for_url('show')}/#{url_identifier}"
35
- end
31
+ # Generate an example URL that can be called in a browser or through curl
32
+ # @return [String] the example URL
33
+ def show_url
34
+ "#{prefix_for_url('show')}/#{url_identifier}"
35
+ end
36
36
 
37
- # Generate an example URL that can be called in a browser or through curl
38
- # @return [String] the example URL
39
- def fetch_url
40
- "#{prefix_for_url('fetch')}?uri=#{url_identifier}"
41
- end
37
+ # Generate an example URL that can be called in a browser or through curl
38
+ # @return [String] the example URL
39
+ def fetch_url
40
+ "#{prefix_for_url('fetch')}?uri=#{url_identifier}"
41
+ end
42
42
 
43
- def prefix_for_url(action)
44
- subauth = "/#{subauthority_name}" if subauthority_name.present?
45
- "#{QaServer::Engine.qa_engine_mount}/#{action}/linked_data/#{authority_name.downcase}#{subauth}"
46
- end
43
+ def prefix_for_url(action)
44
+ subauth = "/#{subauthority_name}" if subauthority_name.present?
45
+ "#{QaServer::Engine.qa_engine_mount}/#{action}/linked_data/#{authority_name.downcase}#{subauth}"
46
+ end
47
47
 
48
- # Convert identifier into URL safe version with encoding if needed.
49
- def url_identifier
50
- return uri_encode(identifier) if encode?
51
- identifier
52
- end
48
+ # Convert identifier into URL safe version with encoding if needed.
49
+ def url_identifier
50
+ return uri_encode(identifier) if encode?
51
+ identifier
52
+ end
53
53
 
54
- def subauthority?
55
- subauthority_name.present?
56
- end
54
+ def subauthority?
55
+ subauthority_name.present?
56
+ end
57
57
 
58
- def encode?
59
- authority.term_id_expects_uri?
60
- end
58
+ def encode?
59
+ authority.term_id_expects_uri?
60
+ end
61
61
 
62
- def uri_encode(uri)
63
- url_encode(uri).gsub(".", "%2E")
64
- end
62
+ def uri_encode(uri)
63
+ url_encode(uri).gsub(".", "%2E")
64
+ end
65
65
  end
66
66
  end
@@ -17,52 +17,52 @@ module PrependedLinkedData::FindTerm
17
17
  requested_results(full_results)
18
18
  end
19
19
 
20
- private
20
+ private
21
21
 
22
- def setup_find(request_header: {}, language: nil, replacements: {}, subauth: nil, format: nil, performance_data: false) # rubocop:disable Metrics/ParameterLists
23
- QaServer.log_agent_info(request_header[:request])
24
- @start_time_s = QaServer::TimeService.current_time_s
25
- request_header = build_request_header(language: language, replacements: replacements, subauth: subauth, format: format, performance_data: performance_data) if request_header.empty?
26
- @saved_performance_data = performance_data || request_header[:performance_data]
27
- request_header[:performance_data] = true
28
- request_header
29
- end
22
+ def setup_find(request_header: {}, language: nil, replacements: {}, subauth: nil, format: nil, performance_data: false) # rubocop:disable Metrics/ParameterLists
23
+ QaServer.log_agent_info(request_header[:request])
24
+ @start_time_s = QaServer::TimeService.current_time_s
25
+ request_header = build_request_header(language: language, replacements: replacements, subauth: subauth, format: format, performance_data: performance_data) if request_header.empty?
26
+ @saved_performance_data = performance_data || request_header[:performance_data]
27
+ request_header[:performance_data] = true
28
+ request_header
29
+ end
30
30
 
31
- def update_performance_history_record(full_results)
32
- return QaServer.config.performance_cache.destroy(@phid) unless full_results.is_a?(Hash) && full_results.key?(:performance)
33
- updates = { action_time_ms: (QaServer::TimeService.current_time_s - @start_time_s) * 1000,
34
- size_bytes: full_results[:performance][:fetched_bytes],
35
- retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
36
- normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
37
- QaServer.config.performance_cache.update(id: @phid, updates: updates)
38
- QaServer.config.performance_cache.complete_entry(id: @phid)
39
- end
31
+ def update_performance_history_record(full_results)
32
+ return QaServer.config.performance_cache.destroy(@phid) unless full_results.is_a?(Hash) && full_results.key?(:performance)
33
+ updates = { action_time_ms: (QaServer::TimeService.current_time_s - @start_time_s) * 1000,
34
+ size_bytes: full_results[:performance][:fetched_bytes],
35
+ retrieve_plus_graph_load_time_ms: full_results[:performance][:fetch_time_s] * 1000,
36
+ normalization_time_ms: full_results[:performance][:normalization_time_s] * 1000 }
37
+ QaServer.config.performance_cache.update(id: @phid, updates: updates)
38
+ QaServer.config.performance_cache.complete_entry(id: @phid)
39
+ end
40
40
 
41
- # Override to append performance history record id into the URL to allow access to the record in RDF::Graph
42
- def load_graph(url:)
43
- return super if QaServer.config.suppress_performance_gathering?
41
+ # Override to append performance history record id into the URL to allow access to the record in RDF::Graph
42
+ def load_graph(url:)
43
+ return super if QaServer.config.suppress_performance_gathering?
44
44
 
45
- access_start_dt = QaServer::TimeService.current_time
45
+ access_start_dt = QaServer::TimeService.current_time
46
46
 
47
- url += "&phid=#{@phid}"
48
- @full_graph = graph_service.load_graph(url: url)
47
+ url += "&phid=#{@phid}"
48
+ @full_graph = graph_service.load_graph(url: url)
49
49
 
50
- access_end_dt = QaServer::TimeService.current_time
51
- @access_time_s = access_end_dt - access_start_dt
52
- @fetched_size = full_graph.triples.to_s.size if performance_data?
53
- Rails.logger.info("Time to receive data from authority: #{access_time_s}s")
54
- end
50
+ access_end_dt = QaServer::TimeService.current_time
51
+ @access_time_s = access_end_dt - access_start_dt
52
+ @fetched_size = full_graph.triples.to_s.size if performance_data?
53
+ Rails.logger.info("Time to receive data from authority: #{access_time_s}s")
54
+ end
55
55
 
56
- # Temporary override to fix bug. Remove when QA Issue #271 is fixed and a new release is cut
57
- def performance_data?
58
- return super if QaServer.config.suppress_performance_gathering?
59
- @performance_data == true
60
- end
56
+ # Temporary override to fix bug. Remove when QA Issue #271 is fixed and a new release is cut
57
+ def performance_data?
58
+ return super if QaServer.config.suppress_performance_gathering?
59
+ @performance_data == true
60
+ end
61
61
 
62
- def requested_results(full_results)
63
- return full_results if @saved_performance_data || !full_results.is_a?(Hash)
64
- return full_results[:results] unless full_results.key? :response_header
65
- full_results.delete(:performance)
66
- full_results
67
- end
62
+ def requested_results(full_results)
63
+ return full_results if @saved_performance_data || !full_results.is_a?(Hash)
64
+ return full_results[:results] unless full_results.key? :response_header
65
+ full_results.delete(:performance)
66
+ full_results
67
+ end
68
68
  end