Actions
Feature #16646
closedAllow Foreman controllers to be extended to include fields from external plugins
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Description
Problem:
If an external plugin, such as Katello, uses database fields in a view that Foreman prepares in a Foreman controller, additional database queries are run from the view layer as the fields or related tables are requested. In index views, this issue causes N+1 query warnings as the view iterates over each object.
Proposed solution:
Allow index actions to be extended per-controller to use a private class method which provide additional fields to pass to the ActiveRecord::Relation#includes method.
Example:
class HostsController class << self do def index_fields @index_fields ||= {} end def include_index_field(field_hash) index_fields.merge!(field_hash) end end def index @hosts = Host.includes(self.class.index_fields) end end
Updated by Andrew Kofink about 8 years ago
- Related to Bug #16010: "Error: Request Timeout" from hammer when asked to show >400 content hosts added
Updated by Dominic Cleal about 8 years ago
- Category set to Plugin integration
- Status changed from New to Assigned
Updated by The Foreman Bot about 8 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/3887 added
Updated by Ivan Necas about 8 years ago
- Target version changed from 127 to 1.5.1
Updated by Ivan Necas about 8 years ago
- Target version changed from 1.5.1 to 1.4.1
Updated by Lukas Zapletal about 8 years ago
- Related to Refactor #17085: Make use of index scope DSL added
Updated by Shimon Shtein about 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 87f8f03ea2f470076e8e7904c4f419833e81b5f0.
Updated by Dominic Cleal about 8 years ago
- Translation missing: en.field_release set to 189
Actions