Class: QaServer::CheckStatusPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/qa_server/check_status_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorities_list:, connection_status_data:, accuracy_status_data:, comparison_status_data:) ⇒ CheckStatusPresenter

Returns a new instance of CheckStatusPresenter.

Parameters:

  • authorities_list (Array<String>)

    a list of all loaded authorities’ names

  • status_data (Array<Hash>)

    a list of status data for each scenario tested



7
8
9
10
11
12
# File 'app/presenters/qa_server/check_status_presenter.rb', line 7

def initialize(authorities_list:, connection_status_data:, accuracy_status_data:, comparison_status_data:)
  @authorities_list = authorities_list
  @connection_status_data = connection_status_data
  @accuracy_status_data = accuracy_status_data
  @comparison_status_data = comparison_status_data
end

Instance Attribute Details

#accuracy_status_dataArray<Hash> (readonly)

rubocop:disable Style/AsciiComments

Examples:

[ { status: :PASS,
    status_label: '√',
    service: 'ld4l_cache',
    action: 'search',
    authority_name: 'LOCNAMES_LD4L_CACHE',
    subauthority_name: 'person',
    expected: 10,
    actual: 8,
    url: '/qa/search/linked_data/locnames_ld4l_cache/person?q=mark twain&maxRecords=20',
    err_message: '' }, ... ]

Returns:

  • (Array<Hash>)

    A list of status data for each accuracy scenario tested.



45
46
47
# File 'app/presenters/qa_server/check_status_presenter.rb', line 45

def accuracy_status_data
  @accuracy_status_data
end

#authorities_listArray<String> (readonly)

Returns A list of all loaded authorities’ names.

Examples:

‘AGROVOC_DIRECT’, ‘AGROVOC_LD4L_CACHE’, ‘LOCNAMES_LD4L_CACHE’

Returns:

  • (Array<String>)

    A list of all loaded authorities’ names



16
17
18
# File 'app/presenters/qa_server/check_status_presenter.rb', line 16

def authorities_list
  @authorities_list
end

#comparison_status_dataArray<Hash> (readonly)

rubocop:disable Style/AsciiComments

Examples:

[ { status: [:PASS, :FAIL],
    status_label: ['√', 'X'],
    service: ['ld4l_cache', 'ld4l_cache'],
    action: 'search',
    authority_name: ['LOCNAMES_LD4L_CACHE', 'LOCNAMES_NEW_LD4L_CACHE']
    subauthority_name: 'imprint',
    request_data: 'Plantin'
    target: 'http://thesaurus.cerl.org/record/cni00007649',
    expected: [1, 1]
    actual: [1, 2]
    url: ['/qa/search/linked_data/cerl_ld4l_cache/imprint?q=Plantin&maxRecords=8',
          '/qa/search/linked_data/cerl_new_ld4l_cache/imprint?q=Plantin&maxRecords=8']
    err_message: ['',''] }, ... ]

Returns:

  • (Array<Hash>)

    A list of status data for each comparison of accuracy scenarios tested.



64
65
66
# File 'app/presenters/qa_server/check_status_presenter.rb', line 64

def comparison_status_data
  @comparison_status_data
end

#connection_status_dataArray<Hash> (readonly)

rubocop:disable Style/AsciiComments

Examples:

[ { status: :PASS,
    status_label: '√',
    service: 'ld4l_cache',
    action: 'search',
    authority_name: 'LOCNAMES_LD4L_CACHE',
    subauthority_name: 'person',
    url: '/qa/search/linked_data/locnames_ld4l_cache/person?q=mark twain&maxRecords=4',
    err_message: '' }, ... ]

Returns:

  • (Array<Hash>)

    A list of status data for each connection scenario tested.



29
30
31
# File 'app/presenters/qa_server/check_status_presenter.rb', line 29

def connection_status_data
  @connection_status_data
end

Instance Method Details

#accuracy_status_data?Boolean

Returns true if status data exists; otherwise false.

Returns:

  • (Boolean)

    true if status data exists; otherwise false



73
74
75
# File 'app/presenters/qa_server/check_status_presenter.rb', line 73

def accuracy_status_data?
  @accuracy_status_data.present?
end

#accuracy_tests_checkedObject



138
139
140
# File 'app/presenters/qa_server/check_status_presenter.rb', line 138

def accuracy_tests_checked
  accuracy_status_data?
end

#comparison_status_data?Boolean

Returns true if status data exists; otherwise false.

Returns:

  • (Boolean)

    true if status data exists; otherwise false



78
79
80
# File 'app/presenters/qa_server/check_status_presenter.rb', line 78

def comparison_status_data?
  @comparison_status_data.present?
end

#comparison_tests_checkedObject



150
151
152
# File 'app/presenters/qa_server/check_status_presenter.rb', line 150

def comparison_tests_checked
  comparison_status_data?
end

#connection_status_data?Boolean

Returns true if status data exists; otherwise false.

Returns:

  • (Boolean)

    true if status data exists; otherwise false



68
69
70
# File 'app/presenters/qa_server/check_status_presenter.rb', line 68

def connection_status_data?
  @connection_status_data.present?
end

#connection_tests_checkedObject



126
127
128
# File 'app/presenters/qa_server/check_status_presenter.rb', line 126

def connection_tests_checked
  connection_status_data?
end

#label_all_checksObject



158
159
160
# File 'app/presenters/qa_server/check_status_presenter.rb', line 158

def label_all_checks
  "#{value_check_param}_#{value_all_checks}".downcase.to_sym
end

#label_check_accuracyObject



134
135
136
# File 'app/presenters/qa_server/check_status_presenter.rb', line 134

def label_check_accuracy
  "#{value_check_param}_#{value_check_accuracy}".downcase.to_sym
end

#label_check_comparisonObject



146
147
148
# File 'app/presenters/qa_server/check_status_presenter.rb', line 146

def label_check_comparison
  "#{value_check_param}_#{value_check_comparison}".downcase.to_sym
end

#label_check_connectionsObject



122
123
124
# File 'app/presenters/qa_server/check_status_presenter.rb', line 122

def label_check_connections
  "#{value_check_param}_#{value_check_connections}".downcase.to_sym
end

#selected_authorityObject



99
100
101
102
103
104
# File 'app/presenters/qa_server/check_status_presenter.rb', line 99

def selected_authority
  return comparison_status_data.first[:authority_name][0].to_sym if comparison_status_data?
  return connection_status_data.first[:authority_name].to_sym if connection_status_data?
  return accuracy_status_data.first[:authority_name].to_sym if accuracy_status_data?
  ""
end

#selected_comparisonObject



106
107
108
# File 'app/presenters/qa_server/check_status_presenter.rb', line 106

def selected_comparison
  comparison_status_data? ? comparison_status_data.first[:authority_name][1].to_sym : ""
end

#status_label(status) ⇒ String

Returns the name of the css style class to use for the status cell based on the status of the scenario test.

Returns:

  • (String)

    the name of the css style class to use for the status cell based on the status of the scenario test.



88
89
90
91
92
93
94
95
96
97
# File 'app/presenters/qa_server/check_status_presenter.rb', line 88

def status_label(status)
  case status
  when :good
    QaServer::ScenarioRunHistory::GOOD_MARKER
  when :bad
    QaServer::ScenarioRunHistory::BAD_MARKER
  when :unknown
    QaServer::ScenarioRunHistory::UNKNOWN_MARKER
  end
end

#status_style_class(status) ⇒ String

Returns the name of the css style class to use for the status cell based on the status of the scenario test.

Returns:

  • (String)

    the name of the css style class to use for the status cell based on the status of the scenario test.



83
84
85
# File 'app/presenters/qa_server/check_status_presenter.rb', line 83

def status_style_class(status)
  "status-#{status}"
end

#value_all_checksObject



154
155
156
# File 'app/presenters/qa_server/check_status_presenter.rb', line 154

def value_all_checks
  QaServer::AuthorityValidationBehavior::ALL_VALIDATIONS
end

#value_all_collectionsObject



110
111
112
# File 'app/presenters/qa_server/check_status_presenter.rb', line 110

def value_all_collections
  QaServer::CheckStatusController::ALL_AUTHORITIES
end

#value_check_accuracyObject



130
131
132
# File 'app/presenters/qa_server/check_status_presenter.rb', line 130

def value_check_accuracy
  QaServer::AuthorityValidationBehavior::VALIDATE_ACCURACY
end

#value_check_comparisonObject



142
143
144
# File 'app/presenters/qa_server/check_status_presenter.rb', line 142

def value_check_comparison
  QaServer::AuthorityValidationBehavior::VALIDATE_ACCURACY_COMPARISON
end

#value_check_connectionsObject



118
119
120
# File 'app/presenters/qa_server/check_status_presenter.rb', line 118

def value_check_connections
  QaServer::AuthorityValidationBehavior::VALIDATE_CONNECTIONS
end

#value_check_paramObject



114
115
116
# File 'app/presenters/qa_server/check_status_presenter.rb', line 114

def value_check_param
  QaServer::AuthorityValidationBehavior::VALIDATION_TYPE_PARAM
end