Avoid N+1 query in foreman hosts index by declaring proper scope
|Assigned To:||Shimon Shtein|
|Target version:||Foreman - Team Ivan Iteration 12|
|Found in release:||Pull request:||https://github.com/theforeman/foreman_openscap/pull/247|
|Velocity based estimate||-|
|Release||foreman_openscap 0.6.5||Release relationship||Auto|
Add this to plugin declaration:
add_controller_action_scope(::Api::V2::HostsController, :index) do |base_scope| base_scope.includes(:policies) end
Fixes #18841 - Added policies to hosts index api scope
Policies are loaded while calculating compliance status, to avoid
N+1 query we are preloading them.
#3 Updated by Shimon Shtein 5 months ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset foreman_openscap|901f778720f441746e296edd363f8a37c5e73975.