Project

General

Profile

« Previous | Next » 

Revision 8ebbbecf

Added by Shira Maximov almost 6 years ago

Fixes #20891 - Remove hostname from /hosts/x/facts results

View differences:

app/models/fact_value.rb
output
end
def self.build_facts_hash(facts)
hosts = Host.where(:id => facts.group_by(&:host_id).keys).all
hash = {}
facts.each do |fact|
hash[hosts.detect {|h| h.id == fact.host_id}.to_s] ||= {}
hash[hosts.detect {|h| h.id == fact.host_id}.to_s].update({fact.name.to_s => fact.value})
def self.build_facts_hash(values, host_id = nil)
hash = values.group_by(&:host_name).transform_values!{|val| val.map{|v| [v.fact_name_name, v.value]}.to_h}
if host_id && hash.any?
hash.merge! hash.values[0]
end
hash
end

Also available in: Unified diff