Skip to content

Commit

Permalink
Network Subnet total_vms work correctly
Browse files Browse the repository at this point in the history
before:

CloudSubnet#total_vms does not use distinct for the count
CloudNetwork#total_vms does

after: both use distinct (since it is going :through a has_many

https://bugzilla.redhat.com/show_bug.cgi?id=1595583
  • Loading branch information
kbrock committed Jul 9, 2018
1 parent 1bb13c5 commit f0a3dd5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/cloud_subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CloudSubnet < ApplicationRecord

has_many :cloud_subnet_network_ports, :dependent => :destroy
has_many :network_ports, :through => :cloud_subnet_network_ports, :dependent => :destroy
has_many :vms, :through => :network_ports, :source => :device, :source_type => 'VmOrTemplate'
has_many :vms, -> { distinct }, :through => :network_ports, :source => :device, :source_type => 'VmOrTemplate'
has_many :cloud_subnets, :foreign_key => :parent_cloud_subnet_id

has_one :public_network, :through => :network_router, :source => :cloud_network
Expand Down

0 comments on commit f0a3dd5

Please sign in to comment.