From: Galen Charlton Date: Fri, 20 Mar 2015 20:33:39 +0000 (+0000) Subject: set limit on how large of a resultset Clark will build graphs for X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=333b00f78f54981b8ef9274ab25ace0619b4ef51;p=working%2FEvergreen.git set limit on how large of a resultset Clark will build graphs for Attempting to draw a bar chart on a 50,000-row result set can consuming system resources for no particular purpose, so by default Clark Kent will now refuse to generate a bar, pie, or line chart if the resultset has more than 1,000 rows. That limit can be adjusted using a new command-line paramter for clark-kent.pl, --max-rows-for-charts. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index 2e9bbd9899..f2e40565ba 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -31,10 +31,15 @@ use open ':utf8'; my ($count, $config, $sleep_interval, $lockfile, $daemon) = (1, 'SYSCONFDIR/opensrf_core.xml', 10, '/tmp/reporter-LOCK'); +# set upper bound on number of rows in the resultset +# before Clark refuses to try to draw a chart +my $max_rows_for_charts = 1000; + GetOptions( "daemon" => \$daemon, "sleep=i" => \$sleep_interval, "concurrency=i" => \$count, + "max-rows-for-charts=i" => \$max_rows_for_charts, "bootstrap|boostrap=s" => \$config, "lockfile=s" => \$lockfile, ); @@ -544,28 +549,40 @@ sub build_html { # Time for a pie chart if ($r->{chart_pie}) { - my $pics = draw_pie($r, $file); - for my $pic (@$pics) { - print $index "$pic->{name}$br4"; + if (scalar(@{$r->{data}}) > $max_rows_for_charts) { + print $index "Report output has too many rows to make a pie chart$br4"; + } else { + my $pics = draw_pie($r, $file); + for my $pic (@$pics) { + print $index "$pic->{name}$br4"; + } } } print $index $br4; # Time for a bar chart if ($r->{chart_bar}) { - my $pics = draw_bars($r, $file); - for my $pic (@$pics) { - print $index "$pic->{name}$br4"; + if (scalar(@{$r->{data}}) > $max_rows_for_charts) { + print $index "Report output has too many rows to make a bar chart$br4"; + } else { + my $pics = draw_bars($r, $file); + for my $pic (@$pics) { + print $index "$pic->{name}$br4"; + } } } print $index $br4; # Time for a bar chart if ($r->{chart_line}) { - my $pics = draw_lines($r, $file); - for my $pic (@$pics) { - print $index "$pic->{name}$br4"; - } + if (scalar(@{$r->{data}}) > $max_rows_for_charts) { + print $index "Report output has too many rows to make a line chart$br4"; + } else { + my $pics = draw_lines($r, $file); + for my $pic (@$pics) { + print $index "$pic->{name}$br4"; + } + } } # and that's it!