JBAS-1377 New headings report min date
authorBill Erickson <berickxx@gmail.com>
Wed, 16 Nov 2016 21:52:38 +0000 (16:52 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
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 <berickxx@gmail.com>
Open-ILS/web/js/ui/default/cat/authority/new_headings.js

index bf213b6..70fb018 100644 (file)
@@ -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