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



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

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



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

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



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

def connection_tests_checked
  connection_status_data?
end

#label_all_checksObject



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

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

#label_check_accuracyObject



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

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

#label_check_comparisonObject



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

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

#label_check_connectionsObject



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

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

#selected_authorityObject



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

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



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

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.



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

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
86
# File 'app/presenters/qa_server/check_status_presenter.rb', line 83

def status_style_class(status)
  return "status-#{status}" unless status.is_a? Hash
  status[:pending] ? "status-dogear status-#{status[:status]}" : "status-#{status[:status]}"
end

#value_all_checksObject



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

def value_all_checks
  QaServer::AuthorityValidationBehavior::ALL_VALIDATIONS
end

#value_all_collectionsObject



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

def value_all_collections
  QaServer::CheckStatusController::ALL_AUTHORITIES
end

#value_check_accuracyObject



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

def value_check_accuracy
  QaServer::AuthorityValidationBehavior::VALIDATE_ACCURACY
end

#value_check_comparisonObject



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

def value_check_comparison
  QaServer::AuthorityValidationBehavior::VALIDATE_ACCURACY_COMPARISON
end

#value_check_connectionsObject



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

def value_check_connections
  QaServer::AuthorityValidationBehavior::VALIDATE_CONNECTIONS
end

#value_check_paramObject



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

def value_check_param
  QaServer::AuthorityValidationBehavior::VALIDATION_TYPE_PARAM
end