qa_server 7.2.0 → 7.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop_fixme.yml +6 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +38 -0
- data/Rakefile +1 -1
- data/app/assets/stylesheets/qa_server/_check-status.scss +36 -0
- data/app/cache_processors/concerns/qa_server/cache_keys.rb +0 -5
- data/app/cache_processors/qa_server/cache_expiry_service.rb +13 -8
- data/app/cache_processors/qa_server/job_id_cache.rb +29 -0
- data/app/cache_processors/qa_server/performance_cache.rb +34 -34
- data/app/cache_processors/qa_server/performance_day_graph_cache.rb +27 -0
- data/app/cache_processors/qa_server/performance_month_graph_cache.rb +27 -0
- data/app/cache_processors/qa_server/performance_year_graph_cache.rb +27 -0
- data/app/cache_processors/qa_server/scenario_history_cache.rb +7 -7
- data/app/cache_processors/qa_server/scenario_history_graph_cache.rb +12 -17
- data/app/cache_processors/qa_server/scenario_run_cache.rb +8 -8
- data/app/cache_processors/qa_server/scenario_run_failures_cache.rb +7 -7
- data/app/cache_processors/qa_server/scenario_run_summary_cache.rb +7 -7
- data/app/controllers/concerns/qa_server/authority_validation_behavior.rb +49 -44
- data/app/controllers/qa_server/check_status_controller.rb +92 -22
- data/app/controllers/qa_server/fetch_controller.rb +36 -36
- data/app/controllers/qa_server/monitor_status_controller.rb +105 -105
- data/app/jobs/qa_server/history_graph_job.rb +28 -0
- data/app/jobs/qa_server/monitor_tests_job.rb +19 -39
- data/app/jobs/qa_server/performance_day_graph_job.rb +45 -0
- data/app/jobs/qa_server/performance_month_graph_job.rb +45 -0
- data/app/jobs/qa_server/performance_per_byte_job.rb +85 -0
- data/app/jobs/qa_server/performance_year_graph_job.rb +45 -0
- data/app/loggers/qa_server/scenario_logger.rb +74 -4
- data/app/models/concerns/qa_server/performance_history_data_keys.rb +8 -0
- data/app/models/qa_server/authority_scenario.rb +4 -4
- data/app/models/qa_server/authority_status.rb +2 -2
- data/app/models/qa_server/authority_status_failure.rb +1 -1
- data/app/models/qa_server/performance_history.rb +2 -2
- data/app/models/qa_server/scenario_run_history.rb +52 -52
- data/app/models/qa_server/scenario_run_registry.rb +2 -2
- data/app/models/qa_server/scenarios.rb +26 -26
- data/app/models/qa_server/search_scenario.rb +18 -13
- data/app/models/qa_server/term_scenario.rb +29 -29
- data/app/prepends/prepended_linked_data/find_term.rb +40 -40
- data/app/prepends/prepended_linked_data/search_query.rb +36 -36
- data/app/prepends/prepended_rdf/rdf_graph.rb +7 -7
- data/app/presenters/concerns/qa_server/monitor_status/performance_datatable_behavior.rb +32 -32
- data/app/presenters/concerns/qa_server/monitor_status/performance_graph_behavior.rb +64 -64
- data/app/presenters/qa_server/check_status_presenter.rb +63 -7
- data/app/services/concerns/qa_server/gruff_graph.rb +16 -16
- data/app/services/qa_server/authority_loader_service.rb +14 -14
- data/app/services/qa_server/authority_validator_service.rb +1 -0
- data/app/services/qa_server/database_migrator.rb +14 -14
- data/app/services/qa_server/history_graphing_service.rb +30 -30
- data/app/services/qa_server/performance_calculator_service.rb +80 -80
- data/app/services/qa_server/performance_datatable_service.rb +35 -35
- data/app/services/qa_server/performance_graph_data_service.rb +28 -28
- data/app/services/qa_server/performance_graphing_service.rb +58 -58
- data/app/services/qa_server/performance_per_byte_calculator_service.rb +88 -0
- data/app/services/qa_server/performance_per_byte_data_service.rb +41 -0
- data/app/services/qa_server/scenarios_loader_service.rb +1 -1
- data/app/services/qa_server/time_period_service.rb +21 -21
- data/app/validators/qa_server/scenario_validator.rb +99 -87
- data/app/validators/qa_server/search_scenario_validator.rb +67 -61
- data/app/validators/qa_server/term_scenario_validator.rb +20 -15
- data/app/views/qa_server/check_status/index.html.erb +120 -24
- data/config/i18n-tasks.yml +133 -0
- data/config/locales/qa_server.en.yml +15 -0
- data/lib/generators/qa_server/assets_generator.rb +4 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/cerl_ld4l_cache.json +2 -2
- data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_aat_ld4l_cache.json +62 -1
- data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +28 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/isni_ld4l_cache.json +90 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/ligatus_ld4l_cache.json +133 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +248 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +248 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +117 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +135 -3
- data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +1 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +1 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_direct_validation.yml +31 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/agrovoc_ld4l_cache_validation.yml +31 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +23 -11
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/dbpedia_ld4l_cache_validation.yml +33 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_direct_validation.yml +35 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +58 -5
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +256 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +35 -1
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +37 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/isni_ld4l_cache_validation.yml +10 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/ligatus_ld4l_cache_validation.yml +36 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +73 -44
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +31 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +71 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +70 -2
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locperformance_ld4l_cache_validation.yml +6 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +32 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +184 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +51 -1
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/nalt_ld4l_cache_validation.yml +37 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclc_fast_validation.yml +71 -5
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +66 -1
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +57 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +310 -0
- data/lib/qa_server/configuration.rb +28 -24
- data/lib/qa_server/version.rb +1 -1
- data/qa_server.gemspec +2 -1
- data/spec/feature/accuracy_spec.rb +32 -0
- data/spec/i18n_spec.rb +36 -0
- data/spec/spec_helper.rb +4 -0
- metadata +46 -12
- data/app/cache_processors/qa_server/performance_daily_graph_cache.rb +0 -60
- data/app/cache_processors/qa_server/performance_hourly_graph_cache.rb +0 -65
- data/app/cache_processors/qa_server/performance_monthly_graph_cache.rb +0 -60
@@ -5,13 +5,13 @@ module QaServer
|
|
5
5
|
# @return [Qa::Authorities::LinkedData::GenericAuthority] authority instance the scenarios run against
|
6
6
|
attr_reader :authority
|
7
7
|
|
8
|
-
# @return [
|
8
|
+
# @return [Symbol] name of the authority the scenarios run against (e.g. :AGROVOC_DIRECT)
|
9
9
|
attr_reader :authority_name
|
10
10
|
|
11
11
|
# @return [String] identifies the primary service provider (e.g. 'ld4l_cache', 'direct', etc.)
|
12
12
|
attr_reader :service
|
13
13
|
|
14
|
-
# @return [String] name of the subauthority the scenario runs against
|
14
|
+
# @return [String] name of the subauthority the scenario runs against (e.g. 'person')
|
15
15
|
attr_reader :subauthority_name
|
16
16
|
|
17
17
|
# @return [Integer] the minimum size of data that must be returned for the scenario to be considered passing
|
@@ -21,14 +21,14 @@ module QaServer
|
|
21
21
|
MIN_EXPECTED_SIZE = 200
|
22
22
|
|
23
23
|
# @param authority [Qa::Authorities::LinkedData::GenericAuthority] the instance of the QA authority
|
24
|
-
# @param
|
24
|
+
# @param authority_name [Symbol] the name of the authority the scenario tests (e.g. :AGROVOC_DIRECT)
|
25
25
|
# @param authority_scenario_config [Hash] configurations from the yml file that pertain to all scenarios regardless of type
|
26
26
|
# @param scenario_config [Hash] configuration from the yml file that are specific to a type of scenario
|
27
27
|
def initialize(authority:, authority_name:, authority_scenario_config:, scenario_config: nil)
|
28
28
|
@authority = authority
|
29
29
|
@authority_name = authority_name
|
30
30
|
@service = authority_scenario_config['service']
|
31
|
-
@context = authority_scenario_config.fetch('context', false)
|
31
|
+
@context = scenario_config.key?("position") ? false : authority_scenario_config.fetch('context', false)
|
32
32
|
@subauthority_name = DEFAULT_SUBAUTH
|
33
33
|
@min_result_size = MIN_EXPECTED_SIZE
|
34
34
|
end
|
@@ -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 <
|
4
|
+
class AuthorityStatus < ApplicationRecord
|
5
5
|
self.table_name = 'authority_status'
|
6
|
-
has_many :authority_status_failure,
|
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 <
|
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 <
|
4
|
+
class PerformanceHistory < ApplicationRecord
|
5
5
|
self.table_name = 'performance_history'
|
6
6
|
|
7
|
-
enum action:
|
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,11 +1,11 @@
|
|
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 <
|
4
|
+
class ScenarioRunHistory < ApplicationRecord
|
5
5
|
self.table_name = 'scenario_run_history'
|
6
6
|
belongs_to :scenario_run_registry
|
7
|
-
enum scenario_type:
|
8
|
-
enum status:
|
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'
|
@@ -96,66 +96,66 @@ module QaServer
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
|
99
|
+
private
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
def day_count(auth, days)
|
102
|
+
days&.key?(auth) ? days[auth] : 0
|
103
|
+
end
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
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
|
114
113
|
end
|
114
|
+
end
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
def authorities_in_run(run_id:)
|
117
|
+
QaServer::ScenarioRunHistory.where(scenario_run_registry_id: run_id).pluck(:authority_name).uniq
|
118
|
+
end
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
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
|
122
|
+
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
133
133
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
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
|
141
140
|
end
|
141
|
+
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
143
|
+
def expected_time_period
|
144
|
+
QaServer.config.historical_datatable_default_time_period
|
145
|
+
end
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
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
|
158
157
|
end
|
158
|
+
end
|
159
159
|
end
|
160
160
|
end
|
161
161
|
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 <
|
4
|
+
class ScenarioRunRegistry < ApplicationRecord
|
5
5
|
self.table_name = 'scenario_run_registry'
|
6
|
-
has_many :scenario_run_history,
|
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
|
-
|
35
|
+
private
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
57
|
+
def authority_scenario_config
|
58
|
+
scenarios_config[AUTHORITY_SCENARIO]
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def term_scenarios_config
|
62
|
+
scenarios_config[TERM_SCENARIOS] || []
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
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,22 @@ module QaServer
|
|
42
43
|
"#{prefix}?q=#{query}#{url_replacements}#{context}"
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
+
def pending?
|
47
|
+
@pending
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
60
|
+
def subauthority?
|
61
|
+
subauthority_name.present?
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
@@ -26,41 +26,41 @@ module QaServer
|
|
26
26
|
authority.term_id_expects_uri? ? fetch_url : show_url
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
private
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
54
|
+
def subauthority?
|
55
|
+
subauthority_name.present?
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def encode?
|
59
|
+
authority.term_id_expects_uri?
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
20
|
+
private
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
45
|
+
access_start_dt = QaServer::TimeService.current_time
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
url += "&phid=#{@phid}"
|
48
|
+
@full_graph = graph_service.load_graph(url: url)
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|