app/services/katello/applicability/applicable_content_helper.rb in katello-3.17.1 vs app/services/katello/applicability/applicable_content_helper.rb in katello-3.17.2
- old
+ new
@@ -76,11 +76,12 @@
joins("INNER JOIN katello_repository_rpms ON
katello_rpms.id = katello_repository_rpms.rpm_id").
joins("INNER JOIN katello_installed_packages ON
katello_rpms.name = katello_installed_packages.name AND
katello_rpms.arch = katello_installed_packages.arch AND
- katello_rpms.evr > katello_installed_packages.evr").
+ katello_rpms.evr > katello_installed_packages.evr AND
+ katello_installed_packages.id in (#{newest_distinct_installed_packages_query})").
joins("LEFT JOIN katello_module_stream_rpms ON
katello_rpms.id = katello_module_stream_rpms.rpm_id").
joins("INNER JOIN katello_host_installed_packages ON
katello_installed_packages.id = katello_host_installed_packages.installed_package_id").
where("katello_repository_rpms.repository_id in (:bound_library_repos)",
@@ -88,9 +89,19 @@
where("katello_host_installed_packages.host_id = :content_facet_id",
:content_facet_id => self.content_facet.host.id).
where("katello_module_stream_rpms.module_stream_id is null or
katello_module_stream_rpms.module_stream_id in (:enabled_module_streams)",
:enabled_module_streams => enabled_module_stream_ids).pluck(:id).uniq
+ end
+
+ def newest_distinct_installed_packages_query
+ "SELECT DISTINCT ON (katello_installed_packages.name) katello_installed_packages.id " \
+ "FROM katello_installed_packages INNER JOIN " \
+ "katello_host_installed_packages ON " \
+ "katello_installed_packages.id = " \
+ "katello_host_installed_packages.installed_package_id " \
+ "WHERE katello_host_installed_packages.host_id = " \
+ "#{content_facet.host.id} ORDER BY katello_installed_packages.name, katello_installed_packages.evr DESC"
end
def applicable_differences
consumer_ids = content_facet.send(applicable_units).pluck("#{content_unit_class.table_name}.id")
content_ids = fetch_content_ids