Skip to content

Commit

Permalink
Merge pull request #22625 from bdunne/allowed_storages_faster
Browse files Browse the repository at this point in the history
Filter storages in the database rather than in ruby.

(cherry picked from commit e5acb48)
  • Loading branch information
agrare authored and Fryguy committed Jul 25, 2023
1 parent d3638b1 commit 9f25613
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions app/models/miq_request_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1075,11 +1075,8 @@ def allowed_storages(_options = {})

rails_logger('allowed_storages', 0)
st = Time.now
MiqPreloader.preload(hosts, :storages => {}, :host_storages => :storage)

storages = hosts.each_with_object({}) do |host, hash|
host.writable_accessible_storages.each { |s| hash[s.id] = s }
end.values
storages = Storage.where(:id => HostStorage.writable_accessible.where(:host => hosts).select(:storage_id))
selected_storage_profile_id = get_value(@values[:placement_storage_profile])
if selected_storage_profile_id
storages.reject! { |s| !s.storage_profiles.pluck(:id).include?(selected_storage_profile_id) }
Expand Down

0 comments on commit 9f25613

Please sign in to comment.