Skip to content

Commit

Permalink
Create method for failing status checks
Browse files Browse the repository at this point in the history
In order to show the status check problems, they need to be fetched
from the status api

Co-authored-by: Christian Bruckmayer <cbruckmayer@suse.com>
  • Loading branch information
krauselukas and ChrisBr committed Nov 21, 2018
1 parent 73cdd5f commit 2f7be24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def current_missing_checks
(relevant_status_reports + relevant_status_reports_for_architectures).map(&:missing_checks).flatten
end

def failed_status_checks
@failed_status_checks ||= relevant_checks.where(state: Status::Check::FAILED_STATES) +
relevant_checks_for_architectures.where(state: Status::Check::FAILED_STATES)
end

private

def cache_problems
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/status/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Status::Check < ApplicationRecord
validates :state, :name, presence: true
# TODO: This should be an ENUM
VALID_STATES = %w[pending error failure success].freeze
FAILED_STATES = %w[error failure].freeze
validates :state, inclusion: {
in: VALID_STATES,
message: "State '%{value}' is not a valid. Valid states are: #{VALID_STATES.join(', ')}"
Expand Down Expand Up @@ -47,7 +48,7 @@ def success?
end

def failed?
%w[error failure].include?(state)
FAILED_STATES.include?(state)
end

#### Alias of methods
Expand Down

0 comments on commit 2f7be24

Please sign in to comment.