Skip to content

Commit

Permalink
Fixes #36943 - reduce the amount of queries to get the errata counts
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard authored and ianballou committed Jan 9, 2024
1 parent d8c443c commit 96da01c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/katello/host/content_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ def errata_counts
}
installable_hash[:total] = installable_hash.values.inject(:+)
# same for applicable, but we need to get the counts from the db
applicable_errata_counts = applicable_errata.pluck(:errata_type).tally
applicable_hash = {
:security => applicable_errata.security.count,
:bugfix => applicable_errata.bugfix.count,
:enhancement => applicable_errata.enhancement.count
:bugfix => applicable_errata_counts.values_at(*Katello::Erratum::BUGZILLA).compact.sum,
:security => applicable_errata_counts.values_at(*Katello::Erratum::SECURITY).compact.sum,
:enhancement => applicable_errata_counts.values_at(*Katello::Erratum::ENHANCEMENT).compact.sum
}
applicable_hash[:total] = applicable_hash.values.inject(:+)
applicable_hash[:total] = applicable_errata_counts.values.sum

# keeping installable at the top level for backward compatibility
installable_hash.merge({
:applicable => applicable_hash
Expand Down

0 comments on commit 96da01c

Please sign in to comment.