qa_server 7.5.1 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_fixme.yml +3 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +28 -0
- data/app/assets/stylesheets/qa_server/_check-status.scss +4 -0
- data/app/assets/stylesheets/qa_server/_monitor-status.scss +45 -0
- data/app/cache_processors/concerns/qa_server/cache_keys.rb +1 -0
- data/app/cache_processors/qa_server/scenario_history_cache.rb +19 -1
- data/app/controllers/qa_server/monitor_status_controller.rb +39 -9
- data/app/models/qa_server/scenario_run_history.rb +12 -3
- data/app/models/qa_server/search_scenario.rb +6 -0
- data/app/presenters/qa_server/check_status_presenter.rb +1 -1
- data/app/presenters/qa_server/monitor_status/current_status_presenter.rb +9 -8
- data/app/presenters/qa_server/monitor_status/history_presenter.rb +55 -4
- data/app/presenters/qa_server/monitor_status/history_up_down_presenter.rb +58 -0
- data/app/presenters/qa_server/monitor_status_presenter.rb +7 -2
- data/app/services/qa_server/history_up_down_service.rb +103 -0
- data/app/services/qa_server/time_service.rb +6 -0
- data/app/views/qa_server/check_status/index.html.erb +7 -6
- data/app/views/qa_server/monitor_status/_test_summary.html.erb +1 -1
- data/app/views/qa_server/monitor_status/_test_up_down_connection_history.html.erb +30 -0
- data/app/views/qa_server/monitor_status/index.html.erb +2 -1
- data/config/locales/qa_server.en.yml +8 -7
- data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_tgn_ld4l_cache.json +24 -14
- data/lib/generators/qa_server/templates/config/authorities/linked_data/getty_ulan_ld4l_cache.json +104 -8
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo2_ld4l_cache.json +4 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo3_ld4l_cache.json +4 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locnames_rwo_ld4l_cache.json +4 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/locvocabs_ld4l_cache.json +1 -1
- data/lib/generators/qa_server/templates/config/authorities/linked_data/mesh_nlm_ld4l_cache.json +1 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_direct.json +4 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/oclcfast_ld4l_cache.json +1 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/cerl_ld4l_cache_validation.yml +3 -3
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/geonames_ld4l_cache_validation.yml +2 -5
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_aat_ld4l_cache_validation.yml +0 -3
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_tgn_ld4l_cache_validation.yml +3 -7
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/getty_ulan_ld4l_cache_validation.yml +5 -5
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locdemographics_ld4l_cache_validation.yml +0 -4
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locgenres_ld4l_cache_validation.yml +0 -9
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_ld4l_cache_validation.yml +1 -7
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo2_ld4l_cache_validation.yml +78 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo3_ld4l_cache_validation.yml +73 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locnames_rwo_ld4l_cache_validation.yml +11 -11
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locsubjects_ld4l_cache_validation.yml +1 -3
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/locvocabs_ld4l_cache_validation.yml +246 -0
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/mesh_nlm_ld4l_cache_validation.yml +8 -5
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_direct_validation.yml +13 -7
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/oclcfast_ld4l_cache_validation.yml +19 -3
- data/lib/generators/qa_server/templates/config/authorities/linked_data/scenarios/rda_registry_ld4l_cache_validation.yml +0 -3
- data/lib/generators/qa_server/templates/config/initializers/qa_server.rb +8 -0
- data/lib/qa_server/configuration.rb +14 -0
- data/lib/qa_server/version.rb +1 -1
- data/qa_server.gemspec +5 -5
- data/spec/feature/accuracy_spec.rb +1 -1
- data/spec/i18n_spec.rb +0 -1
- data/spec/lib/configuration_spec.rb +22 -0
- data/spec/presenters/qa_server/monitor_status/history_presenter_spec.rb +81 -0
- data/spec/services/qa_server/history_up_down_service_spec.rb +86 -0
- metadata +39 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c71b17c28452d0503ee1afd8ee920dbaa12332e578890d02527a402ce1a793
|
4
|
+
data.tar.gz: b569538f771243239ff2fe85428fbe11b9dd948947aa90e598a12c513aa2e4e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96ae15dfd8d90bab80600eea28865a6749347bd084df9771b0864e5d58c803bfb7dc23bff8025f4939ca78c5dfbbfa452a0a8f7fe028acb3c85ee7c3374d78ee
|
7
|
+
data.tar.gz: 04f668c250e1f95188ad2a0553b2ab8a09f33415e4a9028024e4ce97407aa1af041be643dbb6f7b603e61887df8f3b0d7b3b80d7a41c0c194aaa579cb07cd03d
|
data/.rubocop_fixme.yml
CHANGED
data/.travis.yml
CHANGED
@@ -26,7 +26,7 @@ env:
|
|
26
26
|
# It should be sufficient to test only the latest of the patch versions for a minor version, they
|
27
27
|
# should be compatible across patch versions (only bug fixes are released in patch versions).
|
28
28
|
matrix:
|
29
|
-
- "RAILS_VERSION=5.2.
|
29
|
+
- "RAILS_VERSION=5.2.5"
|
30
30
|
|
31
31
|
services:
|
32
32
|
- redis-server
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
### 7.9.0 (2021-04-16)
|
2
|
+
|
3
|
+
* Add chart showing simulated graph (in table) of the last 30 days of up-down connection data
|
4
|
+
|
5
|
+
### 7.8.0 (2021-04-14)
|
6
|
+
|
7
|
+
* add geographic subauth for Mesh-NLM
|
8
|
+
* dogear expected and actual cells when accuracy test is pending
|
9
|
+
|
10
|
+
### 7.7.1 (2021-04-14)
|
11
|
+
|
12
|
+
* fix background colors in historical uptime table
|
13
|
+
|
14
|
+
### 7.7.0 (2021-04-13)
|
15
|
+
|
16
|
+
* remove unused translations
|
17
|
+
* show notification when refreshing starts on monitor status page
|
18
|
+
* hide data in Authority Connection History for non-active authorities
|
19
|
+
* loosen threshold for caution in historical uptime table
|
20
|
+
* minor tweaks missed in original sync
|
21
|
+
|
22
|
+
### 7.6.0 (2021-04-12)
|
23
|
+
|
24
|
+
* update authority configs and test scenarios to use the new cache indexing with results stored as blobs in the index
|
25
|
+
* update to Rails 5.2.5
|
26
|
+
* update dependencies
|
27
|
+
* fix exception when first time running monitor status
|
28
|
+
|
1
29
|
### 7.5.1 (2020-12-08)
|
2
30
|
|
3
31
|
* define missing i18n translations
|
@@ -88,6 +88,10 @@ td.bold-left-border {
|
|
88
88
|
border-left: 2px solid black;
|
89
89
|
}
|
90
90
|
|
91
|
+
.status-dogear {
|
92
|
+
background: linear-gradient(135deg, #333 0%, #333 10%, transparent 10%, transparent 100%);
|
93
|
+
}
|
94
|
+
|
91
95
|
.status-good {
|
92
96
|
text-align: center;
|
93
97
|
background-color: #ccffcc;
|
@@ -53,3 +53,48 @@ div#performance-by-the-day {
|
|
53
53
|
div#performance-by-the-month {
|
54
54
|
display: none;
|
55
55
|
}
|
56
|
+
|
57
|
+
table.up-down-history {
|
58
|
+
border: none;
|
59
|
+
}
|
60
|
+
|
61
|
+
td.up-down-history {
|
62
|
+
font-size: .8em;
|
63
|
+
font-style: italic;
|
64
|
+
border: none;
|
65
|
+
}
|
66
|
+
th.up-down-history {
|
67
|
+
width: 20px;
|
68
|
+
border: none;
|
69
|
+
}
|
70
|
+
|
71
|
+
td.connection-up-down {
|
72
|
+
border-right: 8px white solid;
|
73
|
+
border-left: 8px white solid;
|
74
|
+
border-top: none;
|
75
|
+
border-bottom: 3px white solid;
|
76
|
+
}
|
77
|
+
|
78
|
+
td.connection-no-data {
|
79
|
+
background-color: white;
|
80
|
+
}
|
81
|
+
|
82
|
+
td.connection-fully-up {
|
83
|
+
background-color: #19AE19;
|
84
|
+
}
|
85
|
+
|
86
|
+
td.connection-mostly-up {
|
87
|
+
background-color: #19AEA7;
|
88
|
+
}
|
89
|
+
|
90
|
+
td.connection-timeouts {
|
91
|
+
background-color: #EDF908;
|
92
|
+
}
|
93
|
+
|
94
|
+
td.connection-barely-up {
|
95
|
+
background-color: #AE7619;
|
96
|
+
}
|
97
|
+
|
98
|
+
td.connection-down {
|
99
|
+
background-color: #CE0303;
|
100
|
+
}
|
@@ -5,6 +5,7 @@ module QaServer
|
|
5
5
|
SCENARIO_RUN_SUMMARY_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_summary_data"
|
6
6
|
SCENARIO_RUN_FAILURE_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_failure_data"
|
7
7
|
SCENARIO_RUN_HISTORY_DATA_CACHE_KEY = "QaServer--CacheKeys--scenario_run_history_data"
|
8
|
+
SCENARIO_RUN_HISTORY_UP_DOWN_DATA_CACHE_KEY = "QaServer--CacheKeys--history_up_down_data"
|
8
9
|
|
9
10
|
PERFORMANCE_DATATABLE_DATA_CACHE_KEY = "QaServer--Cache--performance_datatable_data"
|
10
11
|
end
|
@@ -2,8 +2,9 @@
|
|
2
2
|
# Maintain a cache of data for Authority Connection History table displayed on Monitor Status page
|
3
3
|
module QaServer
|
4
4
|
class ScenarioHistoryCache
|
5
|
-
class_attribute :scenario_history_class
|
5
|
+
class_attribute :scenario_history_class, :scenario_up_down_class
|
6
6
|
self.scenario_history_class = QaServer::ScenarioRunHistory
|
7
|
+
self.scenario_up_down_class = QaServer::HistoryUpDownService
|
7
8
|
|
8
9
|
class << self
|
9
10
|
include QaServer::CacheKeys
|
@@ -21,12 +22,29 @@ module QaServer
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
# Get a status for each of the last 30 days for queries that succeeded or failed.
|
26
|
+
# @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
|
27
|
+
# @returns [Hash<Array>] status for the last 30 days for each authority
|
28
|
+
# @example { auth_name => [:fully_up, :fully_up, :down, :mostly_up, ... ], ... }
|
29
|
+
# { 'agrovoc' => [ :fully_up, :fully_up, :down, :mostly_up, ...],
|
30
|
+
# 'geonames_ld4l_cache' => [ :fully_up, :mostly_up, :down, :fully_up, :timeouts, ...] }
|
31
|
+
def historical_up_down_data(force: false)
|
32
|
+
Rails.cache.fetch(cache_key_for_historical_up_down_data, expires_in: next_expiry, race_condition_ttl: 30.seconds, force: force) do
|
33
|
+
QaServer.config.monitor_logger.debug("(QaServer::ScenarioHistoryCache) - CALCULATING UP-DOWN STATUS HISTORY of scenario runs (force: #{force})")
|
34
|
+
scenario_up_down_class.new.last_30_days
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
24
38
|
private
|
25
39
|
|
26
40
|
def cache_key_for_historical_data
|
27
41
|
SCENARIO_RUN_HISTORY_DATA_CACHE_KEY
|
28
42
|
end
|
29
43
|
|
44
|
+
def cache_key_for_historical_up_down_data
|
45
|
+
SCENARIO_RUN_HISTORY_UP_DOWN_DATA_CACHE_KEY
|
46
|
+
end
|
47
|
+
|
30
48
|
def next_expiry
|
31
49
|
QaServer::CacheExpiryService.cache_expiry
|
32
50
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# Controller for Monitor Status header menu item
|
3
3
|
module QaServer
|
4
|
-
class MonitorStatusController < ApplicationController
|
4
|
+
class MonitorStatusController < ApplicationController # rubocop:disable Metrics/ClassLength
|
5
5
|
layout 'qa_server'
|
6
6
|
|
7
7
|
include QaServer::AuthorityValidationBehavior
|
@@ -19,9 +19,10 @@ module QaServer
|
|
19
19
|
@presenter = presenter_class.new(current_summary: latest_summary,
|
20
20
|
current_failure_data: latest_failures,
|
21
21
|
historical_summary_data: historical_data,
|
22
|
+
historical_up_down_data: historical_up_down_data,
|
22
23
|
performance_data: performance_table_data)
|
23
24
|
QaServer.config.monitor_logger.debug("~~~~~~~~ DONE rendering monitor status")
|
24
|
-
render 'index', status: :internal_server_error if latest_summary
|
25
|
+
render 'index', status: :internal_server_error if latest_summary&.failing_authority_count&.positive?
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
@@ -43,13 +44,13 @@ module QaServer
|
|
43
44
|
|
44
45
|
# @returns [QaServer::ScenarioRunSummary] summary statistics on the latest run
|
45
46
|
def latest_summary
|
46
|
-
QaServer::ScenarioRunSummaryCache.summary_for_run(run: latest_test_run)
|
47
|
+
latest_test_run ? QaServer::ScenarioRunSummaryCache.summary_for_run(run: latest_test_run) : nil
|
47
48
|
end
|
48
49
|
|
49
50
|
# @returns [Array<Hash>] scenario details for any failing scenarios in the latest run
|
50
51
|
# @see QaServer::ScenarioRunHistory#run_failures for structure of output
|
51
52
|
def latest_failures
|
52
|
-
QaServer::ScenarioRunFailuresCache.failures_for_run(run: latest_test_run)
|
53
|
+
latest_test_run ? QaServer::ScenarioRunFailuresCache.failures_for_run(run: latest_test_run) : nil
|
53
54
|
end
|
54
55
|
|
55
56
|
# Get a summary level of historical data
|
@@ -59,6 +60,13 @@ module QaServer
|
|
59
60
|
@historical_data ||= QaServer::ScenarioHistoryCache.historical_summary(force: refresh_history?)
|
60
61
|
end
|
61
62
|
|
63
|
+
# Get a summary level of historical data
|
64
|
+
# @returns [Array<Hash>] summary of passing/failing tests for each authority
|
65
|
+
# @see QaServer::ScenarioRunHistory#historical_summary for structure of output
|
66
|
+
def historical_up_down_data
|
67
|
+
@historical_up_down_data ||= QaServer::ScenarioHistoryCache.historical_up_down_data(force: refresh_history?)
|
68
|
+
end
|
69
|
+
|
62
70
|
def update_historical_graph
|
63
71
|
return unless QaServer.config.display_historical_graph?
|
64
72
|
QaServer::ScenarioHistoryGraphCache.generate_graph(data: historical_data, force: refresh_history?)
|
@@ -77,7 +85,8 @@ module QaServer
|
|
77
85
|
end
|
78
86
|
|
79
87
|
def refresh?
|
80
|
-
|
88
|
+
return @refresh unless @refresh.nil?
|
89
|
+
@refresh ||= params.key?(:refresh) && validate_auth_reload_token("refresh status")
|
81
90
|
end
|
82
91
|
|
83
92
|
def refresh_all?
|
@@ -86,15 +95,36 @@ module QaServer
|
|
86
95
|
end
|
87
96
|
|
88
97
|
def refresh_tests?
|
89
|
-
|
98
|
+
return @refresh_tests unless @refresh_tests.nil?
|
99
|
+
@refresh_tests = refresh? && (refresh_all? || params[:refresh].casecmp?('tests'))
|
100
|
+
if @refresh_tests
|
101
|
+
msg = I18n.t('qa_server.monitor_status.refreshing_tests')
|
102
|
+
logger.info msg
|
103
|
+
flash.now[:success] = msg
|
104
|
+
end
|
105
|
+
@refresh_tests
|
90
106
|
end
|
91
107
|
|
92
108
|
def refresh_history?
|
93
|
-
|
109
|
+
return @refresh_history unless @refresh_history.nil?
|
110
|
+
@refresh_history = refresh? && (refresh_all? || params[:refresh].casecmp?('history'))
|
111
|
+
if @refresh_history
|
112
|
+
msg = I18n.t('qa_server.monitor_status.refreshing_history')
|
113
|
+
logger.info msg
|
114
|
+
flash.now[:success] = msg
|
115
|
+
end
|
116
|
+
@refresh_history
|
94
117
|
end
|
95
118
|
|
96
119
|
def refresh_performance?
|
97
|
-
|
120
|
+
return @refresh_performance unless @refresh_performance.nil?
|
121
|
+
@refresh_performance = refresh? && (refresh_all? || params[:refresh].casecmp?('performance'))
|
122
|
+
if @refresh_performance
|
123
|
+
msg = I18n.t('qa_server.monitor_status.refreshing_performance')
|
124
|
+
logger.info msg
|
125
|
+
flash.now[:success] = msg
|
126
|
+
end
|
127
|
+
@refresh_performance
|
98
128
|
end
|
99
129
|
|
100
130
|
def refresh_performance_table?
|
@@ -117,7 +147,7 @@ module QaServer
|
|
117
147
|
token = params.key?(:auth_token) ? params[:auth_token] : nil
|
118
148
|
valid = Qa.config.valid_authority_reload_token?(token)
|
119
149
|
return true if valid
|
120
|
-
msg =
|
150
|
+
msg = I18n.t('qa_server.monitor_status.permission_denied', action: action)
|
121
151
|
logger.warn msg
|
122
152
|
flash.now[:error] = msg
|
123
153
|
false
|
@@ -1,7 +1,7 @@
|
|
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 < ApplicationRecord
|
4
|
+
class ScenarioRunHistory < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
5
5
|
self.table_name = 'scenario_run_history'
|
6
6
|
belongs_to :scenario_run_registry
|
7
7
|
enum scenario_type: { connection: 0, accuracy: 1, performance: 2 }, _suffix: :type
|
@@ -11,9 +11,9 @@ module QaServer
|
|
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,12 +92,21 @@ 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
100
|
private
|
100
101
|
|
102
|
+
def active_authority?(auth)
|
103
|
+
active_authorities.include? auth.to_sym
|
104
|
+
end
|
105
|
+
|
106
|
+
def active_authorities
|
107
|
+
@active_authorities = authority_lister_class.authorities_list
|
108
|
+
end
|
109
|
+
|
101
110
|
def day_count(auth, days)
|
102
111
|
days&.key?(auth) ? days[auth] : 0
|
103
112
|
end
|
@@ -81,7 +81,7 @@ module QaServer
|
|
81
81
|
|
82
82
|
# @return [String] the name of the css style class to use for the status cell based on the status of the scenario test.
|
83
83
|
def status_style_class(status)
|
84
|
-
"status-#{status}"
|
84
|
+
status[:pending] ? "status-dogear status-#{status[:status]}" : "status-#{status[:status]}"
|
85
85
|
end
|
86
86
|
|
87
87
|
# @return [String] the name of the css style class to use for the status cell based on the status of the scenario test.
|
@@ -13,12 +13,13 @@ module QaServer::MonitorStatus
|
|
13
13
|
|
14
14
|
# @return [ActiveSupport::TimeWithZone] date time stamp of last test run
|
15
15
|
def last_updated_dt
|
16
|
-
@current_summary.run_dt_stamp
|
16
|
+
@current_summary ? @current_summary.run_dt_stamp : QaServer::TimeService.current_time
|
17
17
|
end
|
18
18
|
|
19
19
|
# @return [String] date with time of last test run
|
20
20
|
def last_updated
|
21
|
-
|
21
|
+
return I18n.t('qa_server.monitor_status.summary.no_data') if @current_summary.blank?
|
22
|
+
I18n.t('qa_server.monitor_status.summary.last_updated', date: QaServer::TimeService.pretty_time(last_updated_dt))
|
22
23
|
end
|
23
24
|
|
24
25
|
# @return [ActiveSupport::TimeWithZone] date time stamp of first recorded test run
|
@@ -33,12 +34,12 @@ module QaServer::MonitorStatus
|
|
33
34
|
|
34
35
|
# @return [Integer] number of loaded authorities
|
35
36
|
def authorities_count
|
36
|
-
@current_summary.authority_count
|
37
|
+
@current_summary ? @current_summary.authority_count : "N/A"
|
37
38
|
end
|
38
39
|
|
39
40
|
# @return [Integer] number of authorities with failing tests in the latest test run
|
40
41
|
def failing_authorities_count
|
41
|
-
@current_failure_data.map { |f| f[:authority_name] }.uniq.count
|
42
|
+
@current_failure_data ? @current_failure_data.map { |f| f[:authority_name] }.uniq.count : "N/A"
|
42
43
|
end
|
43
44
|
|
44
45
|
# @return [String] css style class representing whether all tests passed or any failed
|
@@ -48,17 +49,17 @@ module QaServer::MonitorStatus
|
|
48
49
|
|
49
50
|
# @return [Integer] number of tests in the latest test run
|
50
51
|
def tests_count
|
51
|
-
@current_summary.total_scenario_count
|
52
|
+
@current_summary ? @current_summary.total_scenario_count : 0
|
52
53
|
end
|
53
54
|
|
54
55
|
# @return [Integer] number of passing tests in the latest test run
|
55
56
|
def passing_tests_count
|
56
|
-
@current_summary.passing_scenario_count
|
57
|
+
@current_summary ? @current_summary.passing_scenario_count : 0
|
57
58
|
end
|
58
59
|
|
59
60
|
# @return [Integer] number of failing tests in the latest test run
|
60
61
|
def failing_tests_count
|
61
|
-
@current_summary.failing_scenario_count
|
62
|
+
@current_summary ? @current_summary.failing_scenario_count : 0
|
62
63
|
end
|
63
64
|
|
64
65
|
# @return [String] css style class representing whether all tests passed or any failed
|
@@ -77,7 +78,7 @@ module QaServer::MonitorStatus
|
|
77
78
|
# url: '/qa/search/linked_data/locnames_ld4l_cache/person?q=mark twain&maxRecords=4',
|
78
79
|
# err_message: 'Exception: Something went wrong.' }, ... ]
|
79
80
|
def failures
|
80
|
-
@current_failure_data
|
81
|
+
@current_failure_data ? @current_failure_data : []
|
81
82
|
end
|
82
83
|
|
83
84
|
# @return [Boolean] true if failure data exists for the latest test run; otherwise false
|
@@ -2,8 +2,16 @@
|
|
2
2
|
# This presenter class provides historical testing data needed by the view that monitors status of authorities.
|
3
3
|
module QaServer::MonitorStatus
|
4
4
|
class HistoryPresenter
|
5
|
+
CAUTION_THRESHOLD = 0.05
|
6
|
+
WARNING_THRESHOLD = 0.1
|
7
|
+
|
5
8
|
# @param parent [QaServer::MonitorStatusPresenter] parent presenter
|
6
9
|
# @param historical_summary_data [Array<Hash>] summary of past failuring runs per authority to drive chart
|
10
|
+
# @example historical_summary_data
|
11
|
+
# {
|
12
|
+
# "AGROVOC_DIRECT"=>{:good=>4, :bad=>0},
|
13
|
+
# "AGROVOC_LD4L_CACHE"=>{:good=>4, :bad=>0}
|
14
|
+
# }
|
7
15
|
def initialize(parent:, historical_summary_data:)
|
8
16
|
@parent = parent
|
9
17
|
@historical_summary_data = historical_summary_data
|
@@ -11,8 +19,10 @@ module QaServer::MonitorStatus
|
|
11
19
|
|
12
20
|
# @return [Array<Hash>] historical test data to be displayed (authname, failing, passing)
|
13
21
|
# @example
|
14
|
-
#
|
15
|
-
#
|
22
|
+
# {
|
23
|
+
# "AGROVOC_DIRECT"=>{:good=>4, :bad=>0},
|
24
|
+
# "AGROVOC_LD4L_CACHE"=>{:good=>4, :bad=>0}
|
25
|
+
# }
|
16
26
|
def historical_summary
|
17
27
|
@historical_summary_data
|
18
28
|
end
|
@@ -69,47 +79,88 @@ module QaServer::MonitorStatus
|
|
69
79
|
end
|
70
80
|
end
|
71
81
|
|
82
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
83
|
+
# @return [String] name of the authority (e.g. 'AUTH_NAME')
|
84
|
+
# @example historical_entry
|
85
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
72
86
|
def historical_data_authority_name(historical_entry)
|
73
87
|
historical_entry[0]
|
74
88
|
end
|
75
89
|
|
90
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
91
|
+
# @return [Integer] number of days with passing tests (e.g. 949)
|
92
|
+
# @example historical_entry
|
93
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
76
94
|
def days_authority_passing(historical_entry)
|
77
95
|
historical_entry[1][:good]
|
78
96
|
end
|
79
97
|
|
98
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
99
|
+
# @return [Integer] number of days with failing tests (e.g. 51)
|
100
|
+
# @example historical_entry
|
101
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
80
102
|
def days_authority_failing(historical_entry)
|
81
103
|
historical_entry[1][:bad]
|
82
104
|
end
|
83
105
|
|
106
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
107
|
+
# @return [Integer] number of days tested (e.g. 1000)
|
108
|
+
# @example historical_entry
|
109
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
84
110
|
def days_authority_tested(historical_entry)
|
85
111
|
days_authority_passing(historical_entry) + days_authority_failing(historical_entry)
|
86
112
|
end
|
87
113
|
|
114
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
115
|
+
# @return [Float] percent of failing to passing tests (e.g. 0.05374 )
|
116
|
+
# @example historical_entry
|
117
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
88
118
|
def percent_authority_failing(historical_entry)
|
89
119
|
days_authority_failing(historical_entry).to_f / days_authority_tested(historical_entry)
|
90
120
|
end
|
91
121
|
|
122
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
123
|
+
# @return [String] percent of failing to passing tests (e.g. '5.4%')
|
124
|
+
# @example historical_entry
|
125
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
92
126
|
def percent_authority_failing_str(historical_entry)
|
93
127
|
ActiveSupport::NumberHelper.number_to_percentage(percent_authority_failing(historical_entry) * 100, precision: 1)
|
94
128
|
end
|
95
129
|
|
130
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
131
|
+
# @return [String] css class for background in Days Failing and Percent Failing columns (e.g. 'status-neutral', 'status-unknown', 'status-bad')
|
132
|
+
# @example historical_entry
|
133
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
96
134
|
def failure_style_class(historical_entry)
|
97
|
-
|
98
|
-
|
135
|
+
case percent_authority_failing(historical_entry)
|
136
|
+
when 0.0...CAUTION_THRESHOLD
|
137
|
+
"status-neutral"
|
138
|
+
when CAUTION_THRESHOLD...WARNING_THRESHOLD
|
139
|
+
"status-unknown"
|
140
|
+
else
|
141
|
+
"status-bad"
|
142
|
+
end
|
99
143
|
end
|
100
144
|
|
145
|
+
# @param historical_entry [Array<String,Hash>] data for a single authority including name, # passing tests (good), # failing tests (bad)
|
146
|
+
# @return [String] css class for background in Days Passing column (e.g. 'status-good', 'status-bad')
|
147
|
+
# @example historical_entry
|
148
|
+
# [ 'AUTH_NAME', { good: 949, bad: 51 } ]
|
101
149
|
def passing_style_class(historical_entry)
|
102
150
|
days_authority_passing(historical_entry) <= 0 ? "status-bad" : "status-good"
|
103
151
|
end
|
104
152
|
|
153
|
+
# @return [Boolean] true if historical section should be visible; otherwise false
|
105
154
|
def display_history_details?
|
106
155
|
display_historical_graph? || display_historical_datatable?
|
107
156
|
end
|
108
157
|
|
158
|
+
# @return [Boolean] true if historical graph should be visible; otherwise false
|
109
159
|
def display_historical_graph?
|
110
160
|
QaServer.config.display_historical_graph? && QaServer::HistoryGraphingService.history_graph_image_exists?
|
111
161
|
end
|
112
162
|
|
163
|
+
# @return [Boolean] true if historical datatable should be visible; otherwise false
|
113
164
|
def display_historical_datatable?
|
114
165
|
QaServer.config.display_historical_datatable?
|
115
166
|
end
|