Project

General

Profile

Bug #18841

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

Added by Shimon Shtein almost 2 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

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 (diff)
Added by Shimon Shtein almost 2 years 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 almost 2 years ago

Merge pull request #247 from ShimShtein/18841

Fixes #18841 - Added policies to hosts index api scope

History

#1 Updated by Shimon Shtein almost 2 years ago

Add similar handling to UI hosts controller too.

#2 Updated by The Foreman Bot almost 2 years ago

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

#3 Updated by Shimon Shtein almost 2 years ago

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

#4 Updated by Marek Hulán almost 2 years ago

  • Legacy Backlogs Release (now unused) set to 225

#5 Updated by Ivan Necas almost 2 years ago

  • Target version set to 1.12.0

#6 Updated by Ivan Necas over 1 year ago

  • Target version changed from 1.12.0 to 1.12.2

Also available in: Atom PDF