From db6e89607d973f74f622261ecca52f404e34464e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 25 Jan 2020 18:07:43 +0000 Subject: [PATCH] #696 complete implementation of #688 --- lib/App/Netdisco/DB/ResultSet/Device.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/DB/ResultSet/Device.pm b/lib/App/Netdisco/DB/ResultSet/Device.pm index 04c4dfa1..37584d3f 100644 --- a/lib/App/Netdisco/DB/ResultSet/Device.pm +++ b/lib/App/Netdisco/DB/ResultSet/Device.pm @@ -442,7 +442,8 @@ Results are ordered by the Device DNS and IP fields. =item * -Related rows from the C table will be prefetched. +Column C gives a count of the number of ports on the device +that are actually configured to carry the VLAN. =back @@ -460,13 +461,16 @@ sub carrying_vlan_name { return $rs ->search_rs({}, { order_by => [qw/ me.dns me.ip /], - columns => [ - 'me.ip', 'me.dns', - 'me.model', 'me.os', - 'me.vendor', 'vlans.vlan', - 'vlans.description' - ], - join => 'vlans' + select => [{ count => 'ports.vlan' }], + as => ['pcount'], + columns => [ + 'me.ip', 'me.dns', + 'me.model', 'me.os', + 'me.vendor', 'vlans.vlan', + 'vlans.description' + ], + join => {'vlans' => 'ports'}, + distinct => 1, }) ->search($cond, $attrs); }