Revision 8ebbbecf
Added by Shira Maximov almost 6 years ago
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
Fixes #20891 - Remove hostname from /hosts/x/facts results