From 0af415e391edb09e40ec12ed800791e9dbf9db80 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 30 Dec 2017 22:33:22 +0000 Subject: [PATCH] fix to get aggregate ports in matching order on left and right side --- .../Netdisco/DB/Result/Virtual/DeviceLinks.pm | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm index fe61a2d7..bb449135 100644 --- a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm +++ b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm @@ -7,43 +7,32 @@ use base 'DBIx::Class::Core'; __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); -# notes to future devs: - +# note to future devs: # this query does not use the slave_of field in device_port table to group # ports because what we actually want is total b/w between devices on all # links, regardless of whether those links are in an aggregate. -# PG 8.4 does not have sorting within an aggregate so we cannot ensure that -# left and right ports and names correspond within arrays. this is why the -# right ports are the left's remote_ports (and right_descr should be ignored) - __PACKAGE__->table('device_links'); __PACKAGE__->result_source_instance->is_virtual(1); __PACKAGE__->result_source_instance->view_definition(< ARRAY[dp2.port]) - WHERE dp.ip <= dp2.ip - GROUP BY left_ip, left_port, left_descr, aggspeed, aggports, right_ip, right_port + WHERE dp.remote_port IS NOT NULL + AND dp.type = 'ethernetCsmacd' + AND dp.speed LIKE '%bps' + AND dp.ip <= dp2.ip + GROUP BY left_ip, right_ip ORDER BY dp.ip ENDSQL );