Skip to content

Commit

Permalink
Get checks and status reports by associations
Browse files Browse the repository at this point in the history
Use associations to get status reports and checks for both repositories
and repository_architectures.

All relevant_* methods are based on current status reports, not all of
them.

Co-authored-by: Christian Bruckmayer <cbruckmayer@suse.com>
Co-authored-by: David Kang <dkang@suse.com>
Co-authored-by: Lukas Krause <lkrause@suse.de>
  • Loading branch information
4 people committed Nov 21, 2018
1 parent c0fe889 commit c16ba6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,12 @@ def unassign_managers_group(managers)
relationships.find_by(group: managers, role: role).try(:destroy!)
end

def current_status_reports
repositories.map(&:current_status_report) + repository_architectures.map(&:current_status_report)
def current_checks
relevant_checks + relevant_checks_for_architectures
end

def all_checks
current_status_reports.map(&:checks).flatten
end

def all_missing_checks
current_status_reports.map(&:missing_checks).flatten
def current_missing_checks
(relevant_status_reports + relevant_status_reports_for_architectures).map(&:missing_checks).flatten
end

private
Expand Down Expand Up @@ -161,6 +157,10 @@ def relevant_status_reports
@relevant_status_reports ||= status_reports.where(uuid: repositories.map(&:build_id))
end

def relevant_status_reports_for_architectures
@relevant_status_reports_for_architectures ||= status_reports_for_architectures.where(uuid: repository_architectures.map(&:build_id))
end

def missing_checks?
relevant_status_reports.any? { |report| report.missing_checks.present? }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
locals: { staging_project: @staging_project, items: @staging_project.broken_packages, type: 'broken_packages' }
%tr
= render partial: 'checks',
locals: { checks: @staging_project.all_checks,
missing_checks: @staging_project.all_missing_checks }
locals: { checks: @staging_project.current_checks,
missing_checks: @staging_project.current_missing_checks }
.col-xl-2
= render partial: 'webui/staging/shared/legend'

0 comments on commit c16ba6c

Please sign in to comment.