Skip to content

Commit

Permalink
Refs #37137 - cache AvailableModuleStreams
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Feb 27, 2024
1 parent 65430af commit 5aad7dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/models/katello/concerns/host_managed_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5aad7dc

Please sign in to comment.