diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-03-11 15:22:23 -0800 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-03-11 16:25:22 -0800 |
commit | 8858e40839bd693420ddc791df6b51de79356d2a (patch) | |
tree | 44f73bbd2f5c90665e545361010a79e188c662f6 /lib/puppet/rails/inventory_node.rb | |
parent | 8cfc8f195481bbca7c38a415ef8ba11bd20503a6 (diff) | |
download | puppet-8858e40839bd693420ddc791df6b51de79356d2a.tar.gz puppet-8858e40839bd693420ddc791df6b51de79356d2a.tar.xz puppet-8858e40839bd693420ddc791df6b51de79356d2a.zip |
(#6689) Make inventory_active_record terminus search quickly
This terminus behaves the same on all supported DB platforms, by performing a
limited portion of its query in SQL, and the rest of the comparison in Ruby.
Its results are consistent with the YAML terminus.
Paired-With: Jesse Wolfe
Diffstat (limited to 'lib/puppet/rails/inventory_node.rb')
-rw-r--r-- | lib/puppet/rails/inventory_node.rb | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/lib/puppet/rails/inventory_node.rb b/lib/puppet/rails/inventory_node.rb index b3e321f94..52f8621a4 100644 --- a/lib/puppet/rails/inventory_node.rb +++ b/lib/puppet/rails/inventory_node.rb @@ -1,7 +1,7 @@ require 'puppet/rails/inventory_fact' class Puppet::Rails::InventoryNode < ::ActiveRecord::Base - has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :dependent => :delete_all + has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :foreign_key => :node_id, :dependent => :delete_all named_scope :has_fact_with_value, lambda { |name,value| { @@ -17,18 +17,6 @@ class Puppet::Rails::InventoryNode < ::ActiveRecord::Base } } - named_scope :has_fact, lambda { |name| - { - :conditions => ["inventory_facts.name = ?", name], - :joins => :facts - } - } - - def value_for(fact_name) - fact = facts.find_by_name(fact_name) - fact ? fact.value : nil - end - def facts_to_hash facts.inject({}) do |fact_hash,fact| fact_hash.merge(fact.name => fact.value) |