From 88788534baaa2e622689a2cd8fc3d30f9c2b2e6e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 27 May 2019 15:36:17 +0100 Subject: [PATCH] #589 only show link with highest agg speed if map links between two devices are asymmetric --- lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm | 11 +++++------ lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm | 7 +++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm index 9d2339ca..676aeed4 100644 --- a/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm +++ b/lib/App/Netdisco/DB/Result/Virtual/DeviceLinks.pm @@ -19,8 +19,8 @@ __PACKAGE__->result_source_instance->view_definition(<result_source_instance->view_definition(<result_source_instance->view_definition(< require_login sub { # LINKS + my %seen_link = (); my $links = schema('netdisco')->resultset('Virtual::DeviceLinks')->search({ ($mapshow eq 'neighbors' ? ( -or => [ { left_ip => $qdev->ip }, @@ -175,6 +176,11 @@ ajax '/ajax/data/device/netmap' => require_login sub { }, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' }); while (my $link = $links->next) { + # query is ordered by aggregate speed desc so we see highest speed + # first, which is hopefully the "best" if links are not symmetric + next if exists $seen_link{$link->{left_ip} ."\0". $link->{right_ip}} + or exists $seen_link{$link->{right_ip} ."\0". $link->{left_ip}}; + push @{$data{'links'}}, { FROMID => $link->{left_ip}, TOID => $link->{right_ip}, @@ -184,6 +190,7 @@ ajax '/ajax/data/device/netmap' => require_login sub { ++$ok_dev{$link->{left_ip}}; ++$ok_dev{$link->{right_ip}}; + ++$seen_link{$link->{left_ip} ."\0". $link->{right_ip}}; } # DEVICES (NODES)