From f8cbc52c5a40eddfe30cac0955fd2c23e09a59d9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 20 Nov 2015 21:26:05 +0000 Subject: [PATCH] LP#1516867: set limit on when HTML report output sorting To avoid taking an excessive amount of time to render an HTML report or sort its values, dynamic sorting is enabled only when there are at most 10,000 rows of output. Signed-off-by: Galen Charlton Signed-off-by: Ben Shum --- Open-ILS/src/reporter/clark-kent.pl | 13 +++++++++++-- .../Administration/sortable_html_reports.adoc | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/reporter/clark-kent.pl b/Open-ILS/src/reporter/clark-kent.pl index 758cb2c83d..fabd2dbe0b 100755 --- a/Open-ILS/src/reporter/clark-kent.pl +++ b/Open-ILS/src/reporter/clark-kent.pl @@ -113,6 +113,12 @@ my $resultset_limit = $opt_resultset_limit // 0; $resultset_limit = 0 unless $resultset_limit =~ /^\d+$/; # 0 means no limit +# What follows is an emperically-derived magic number; if +# the row count is larger than this, the table-sorting JavaScript +# won't be loaded to excessive churn when viewing HTML reports +# in the staff client or web browser. +my $sortable_limit = 10000; + my ($dbh,$running,$sth,@reports,$run, $current_time); if ($daemon) { @@ -555,7 +561,6 @@ sub build_html { td,th { border: solid black 1px; } * { font-family: sans-serif; } - CSS @@ -566,7 +571,11 @@ sub build_html { print $raw "".join('', @$_)."\n" for (@{$r->{data}}); } - print $raw ''; + print $raw ''; + if (@{ $r->{data} } <= $sortable_limit) { + print $raw ''; + } + print $raw ''; $raw->close; } diff --git a/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc index 373418e7de..539a576a2c 100644 --- a/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc +++ b/docs/RELEASE_NOTES_NEXT/Administration/sortable_html_reports.adoc @@ -2,4 +2,5 @@ Sortable HTML reports ^^^^^^^^^^^^^^^^^^^^^ HTML reports can now be sorted by clicking on the header for a given column. Clicking on the header toggles between sorting the column in ascending and -descending order. +descending order. Note that sorting is available only when there are +at most 10,000 rows of output. -- 2.43.2