Skip to content

Commit

Permalink
Improve performance of Hardware#ipaddresses
Browse files Browse the repository at this point in the history
Doesn't work with loaded networks though... might not want to merge
this.
  • Loading branch information
NickLaMuro committed Jun 8, 2018
1 parent b30bb43 commit dcd9d69
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/hardware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Hardware < ApplicationRecord
virtual_aggregate :allocated_disk_storage, :disks, :sum, :size

def ipaddresses
@ipaddresses ||= networks.collect(&:ipaddress).compact.uniq + networks.collect(&:ipv6address).compact.uniq
@ipaddresses ||= networks.pluck(:ipaddress, :ipv6address).flatten.tap(&:compact!).uniq!
end

def hostnames
Expand Down

0 comments on commit dcd9d69

Please sign in to comment.