From 7d8102efa827ac355f21f41d4234b7f516141113 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 16 Nov 2016 16:52:38 -0500 Subject: [PATCH] JBAS-1377 New headings report min date Support applying a minimum report date in the new headings report to prevent queries that report on (practically) all headings. This happens when the start date equals or precedes the deployment date for the browse headings create_date column, which is set to NOW() by default. Signed-off-by: Bill Erickson --- .../web/js/ui/default/cat/authority/new_headings.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/cat/authority/new_headings.js b/Open-ILS/web/js/ui/default/cat/authority/new_headings.js index bf213b6944..70fb018559 100644 --- a/Open-ILS/web/js/ui/default/cat/authority/new_headings.js +++ b/Open-ILS/web/js/ui/default/cat/authority/new_headings.js @@ -21,6 +21,15 @@ var template_row; var cached_headings var all_fetched; +// Force a minimum start date for new headings to avoid reporting on +// (practically) all headings, which occurs when the start date preceeds +// or includes the SQL deployment date, which stamps a create_date on +// every heading to NOW(). Such queries cause heavy load and eventually +// time out anyway. +// NOTE: using English dates instead of ISO dates since English +// dates tell Date.parse() to use the local time zone instead of UTC. +var min_start_date = new Date(Date.parse('December 5, 2016 00:00:00')); + var summary_fields = [ 'prev_entry_value', 'entry_value', @@ -133,10 +142,17 @@ function compile_date_filter() { start_date = startDate.attr('value'); end_date = endDate.attr('value'); - if (start_date) { - start_date = openils.Util.getYMD(start_date); + if (!start_date || start_date < min_start_date) { + console.log("Selected start date " + start_date + " is too early. " + + "Using min start date " + min_start_date + " instead"); + + // clone the date since it will get clobbered by getYMD. + startDate.attr('value', min_start_date); + start_date = min_start_date; } + start_date = openils.Util.getYMD(start_date); + if (end_date) { // the end date has to be extended by one day, since the between // query cuts off at midnight (0 hour) on the end date, which -- 2.11.0