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,
);
# Time for a pie chart
if ($r->{chart_pie}) {
- my $pics = draw_pie($r, $file);
- for my $pic (@$pics) {
- print $index "<img src='report-data.html.$pic->{file}' alt='$pic->{name}'/>$br4";
+ if (scalar(@{$r->{data}}) > $max_rows_for_charts) {
+ print $index "<strong>Report output has too many rows to make a pie chart</strong>$br4";
+ } else {
+ my $pics = draw_pie($r, $file);
+ for my $pic (@$pics) {
+ print $index "<img src='report-data.html.$pic->{file}' alt='$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 "<img src='report-data.html.$pic->{file}' alt='$pic->{name}'/>$br4";
+ if (scalar(@{$r->{data}}) > $max_rows_for_charts) {
+ print $index "<strong>Report output has too many rows to make a bar chart</strong>$br4";
+ } else {
+ my $pics = draw_bars($r, $file);
+ for my $pic (@$pics) {
+ print $index "<img src='report-data.html.$pic->{file}' alt='$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 "<img src='report-data.html.$pic->{file}' alt='$pic->{name}'/>$br4";
- }
+ if (scalar(@{$r->{data}}) > $max_rows_for_charts) {
+ print $index "<strong>Report output has too many rows to make a line chart</strong>$br4";
+ } else {
+ my $pics = draw_lines($r, $file);
+ for my $pic (@$pics) {
+ print $index "<img src='report-data.html.$pic->{file}' alt='$pic->{name}'/>$br4";
+ }
+ }
}
# and that's it!