Lp 1811696: Add --update-rmsr option to pingest.pl user/dyrcona/lp1811696-pingest-update-rmsr-option
authorJason Stephenson <jason@sigio.com>
Thu, 24 Jan 2019 16:14:33 +0000 (11:14 -0500)
committerJason Stephenson <jason@sigio.com>
Thu, 24 Jan 2019 16:14:33 +0000 (11:14 -0500)
Add an option to the pingest.pl support script to enable the updating
of reporter.materialized_simple_record entries for the ingested
records.

Add a release note for the new feature.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/support-scripts/pingest.pl
docs/RELEASE_NOTES_NEXT/Administration/pingest_update_rmsr.adoc [new file with mode: 0644]

index d351cfa..9a17f3c 100755 (executable)
@@ -34,6 +34,7 @@ my $skip_attrs;   # Skip the record attributes reingest.
 my $skip_search;  # Skip the search reingest.
 my $skip_facets;  # Skip the facets reingest.
 my $skip_display; # Skip the display reingest.
+my $update_rmsr;  # Update reporter.materialized_simple_record table.
 my $start_id;     # start processing at this bib ID.
 my $end_id;       # stop processing when this bib ID is reached.
 my $max_duration; # max processing duration in seconds
@@ -60,6 +61,7 @@ GetOptions(
     'skip-search'    => \$skip_search,
     'skip-facets'    => \$skip_facets,
     'skip-display'   => \$skip_display,
+    'update-rmsr'    => \$update_rmsr,
     'start-id=i'     => \$start_id,
     'end-id=i'       => \$end_id,
     'pipe'           => \$opt_pipe,
@@ -86,6 +88,10 @@ sub help {
     --skip-display
         Skip the selected reingest component
 
+    --update-rmsr
+        Update reporter.materialized_simple_record entries.
+        This does NOT happen unless this option is specified.
+
     --start-id
         Start processing at this record ID.
 
@@ -202,7 +208,7 @@ while ($count < $lists) {
     if (scalar(@lol) && scalar(@running) < $max_child && !$duration_expired) {
         # Reuse $records for the lulz.
         $records = shift(@lol);
-        if ($skip_search && $skip_facets && $skip_attrs && $skip_display) {
+        if ($skip_search && $skip_facets && $skip_attrs && $skip_display && !$update_rmsr) {
             $count++;
         } else {
             reingest($records);
@@ -272,6 +278,7 @@ sub reingest {
         reingest_attributes($dbh, $list) unless ($skip_attrs);
         reingest_field_entries($dbh, $list)
             unless ($skip_facets && $skip_search && $skip_display);
+        rmsr_update($dbh, $list) if ($update_rmsr);
         $dbh->disconnect();
         exit(0);
     }
@@ -315,3 +322,18 @@ END_OF_INGEST
         }
     }
 }
+
+# Update reporter.materialized_simple_record entries.
+sub rmsr_update {
+    my $dbh = shift;
+    my $list = shift;
+    my $sth = $dbh->prepare('SELECT reporter.simple_record_update(?)');
+    foreach (@$list) {
+        $sth->bind_param(1, $_);
+        if ($sth->execute()) {
+            my $crap = $sth->fetchall_arrayref();
+        } else {
+            warn ("reporter.simple_record_update failed for record $_");
+        }
+    }
+}
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/pingest_update_rmsr.adoc b/docs/RELEASE_NOTES_NEXT/Administration/pingest_update_rmsr.adoc
new file mode 100644 (file)
index 0000000..5be510f
--- /dev/null
@@ -0,0 +1,19 @@
+pingest.pl New --update-rmsr Option
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The pingest.pl support script has a new option, `--update-rmsr`, that
+can be used to update entries in the
+reporter.materialized_simple_record table for the records being
+processed by pingest.pl.  Unlike most of the options, this is not a
+skip option.  It needs to be enabled for this update to take place.
+
+Furthermore, this option is not meant to be used to rebuild the
+reporter.materialized_simple_record table wholesale.  If that is your
+goal, you are better off connecting to the database directly and
+running the following SQL:
+
+[source,sql]
+-----
+SELECT reporter.disable_materialized_simple_record_trigger();
+SELECT reporter.enable_materialized_simple_record_trigger();
+----