Bug #18841

Avoid N+1 query in foreman hosts index by declaring proper scope

Added by Shimon Shtein 17 days ago. Updated 12 days ago.

Status:ClosedSpent time:-
Priority:Normal
Assigned To:Shimon Shtein
Category:-
Target version:Foreman - Team Ivan Iteration 11
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman_openscap/pull/247
Triaged:No
Story points-
Velocity based estimate-
Releaseforeman_openscap 0.6.5Release relationshipAuto

Description

Add this to plugin declaration:

  add_controller_action_scope(::Api::V2::HostsController, :index) do |base_scope|
    base_scope.includes(:policies)
  end

Associated revisions

Revision 901f7787
Added by Shimon Shtein 14 days ago

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.

Revision f1159c1f
Added by Ondřej Pražák 13 days ago

Merge pull request #247 from ShimShtein/18841

Fixes #18841 - Added policies to hosts index api scope

History

#1 Updated by Shimon Shtein 17 days ago

Add similar handling to UI hosts controller too.

#2 Updated by The Foreman Bot 17 days ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Shimon Shtein
  • Pull request https://github.com/theforeman/foreman_openscap/pull/247 added

#3 Updated by Shimon Shtein 13 days ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Marek Hulán 13 days ago

  • Release set to foreman_openscap 0.6.5

#5 Updated by Ivan Necas 12 days ago

  • Target version set to Team Ivan Iteration 11

Also available in: Atom PDF