diff --git a/app/models/katello/concerns/host_managed_extensions.rb b/app/models/katello/concerns/host_managed_extensions.rb index a6f628720d9..1225be42017 100644 --- a/app/models/katello/concerns/host_managed_extensions.rb +++ b/app/models/katello/concerns/host_managed_extensions.rb @@ -326,10 +326,11 @@ def import_enabled_repositories(repos) end def available_module_stream_id_from(name:, stream:, context:) - AvailableModuleStream.find_by!(name: name, stream: stream, context: context).id - rescue ActiveRecord::RecordNotFound - Rails.logger.warn("Module stream not found: name: #{name}, stream: #{stream}, context: #{context}") - nil + Rails.logger.info "Querying" unless defined?(@indexed_available_module_streams) + @indexed_available_module_streams ||= Katello::AvailableModuleStream.all.index_by do |available_module_stream| + "#{available_module_stream.name}-#{available_module_stream.stream}-#{available_module_stream.context}" + end + @indexed_available_module_streams["#{name}-#{stream}-#{context}"]&.id end def import_module_streams(module_streams)