Skip to content

Commit

Permalink
Staging: Take checks of build repositories into account
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Nov 14, 2018
1 parent 513a6b6 commit 68ea19e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/api/app/models/obs_factory/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,23 @@ def fetch_status
@checks = []
@missing_checks = []
repositories.each do |repo|
build_id = repo.build_id
status = repo.status_reports.find_by(uuid: build_id)
if status
@missing_checks += status.missing_checks
@checks += status.checks
else
@missing_checks += repo.required_checks
add_status(repo)
repo.repository_architectures.each do |repo_arch|
add_status(repo_arch)
end
end
end

def add_status(checkable)
status = checkable.status_reports.latest
if status
@missing_checks += status.missing_checks
@checks += status.checks
else
@missing_checks += repo.required_checks
end
end

# Used internally to calculate #broken_packages and #building_repositories
def set_buildinfo
buildresult = Xmlhash.parse(Backend::Api::BuildResults::Status.failed_results(name))
Expand Down
10 changes: 9 additions & 1 deletion src/api/app/models/repository_architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ class RepositoryArchitecture < ApplicationRecord
validates :repository, :architecture, :position, presence: true
validates :repository, uniqueness: { scope: :architecture }

has_many :status_reports, as: :checkable, class_name: 'Status::Report', dependent: :destroy
has_many :status_reports, as: :checkable, class_name: 'Status::Report', dependent: :destroy do
def for_uuid(uuid)
where(status_reports: { uuid: uuid })
end

def latest
for_uuid(proxy_association.owner.build_id)
end
end

def build_id
Backend::Api::Build::Repository.build_id(repository.project.name, repository.name, architecture.name)
Expand Down

0 comments on commit 68ea19e

Please sign in to comment.