From 6b13100b82783263b15eee9508c2901bea7c5563 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Sun, 16 Feb 2014 20:47:48 -0500 Subject: [PATCH] Only query database for select lists when they will be used by the report --- Netdisco/lib/App/Netdisco/Web/Report.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Web/Report.pm b/Netdisco/lib/App/Netdisco/Web/Report.pm index f5221b46..1dccd5fc 100644 --- a/Netdisco/lib/App/Netdisco/Web/Report.pm +++ b/Netdisco/lib/App/Netdisco/Web/Report.pm @@ -8,14 +8,20 @@ get '/report/*' => require_login sub { my ($tag) = splat; # used in the report search sidebar to populate select inputs - my $domain_list - = [ - schema('netdisco')->resultset('NodeNbt')->get_distinct_col('domain') - ]; - my $class_list = [ schema('netdisco')->resultset('DeviceModule') - ->get_distinct_col('class') ]; - my $ssid_list = [ schema('netdisco')->resultset('DevicePortSsid') - ->get_distinct_col('ssid') ]; + my ( $domain_list, $class_list, $ssid_list ); + + if ( $tag eq 'netbios' ) { + $domain_list = [ schema('netdisco')->resultset('NodeNbt') + ->get_distinct_col('domain') ]; + } + elsif ( $tag eq 'moduleinventory' ) { + $class_list = [ schema('netdisco')->resultset('DeviceModule') + ->get_distinct_col('class') ]; + } + elsif ( $tag eq 'portssid' ) { + $ssid_list = [ schema('netdisco')->resultset('DevicePortSsid') + ->get_distinct_col('ssid') ]; + } # trick the ajax into working as if this were a tabbed page params->{tab} = $tag;