pingest --newest-first option
authorBill Erickson <berickxx@gmail.com>
Wed, 2 Mar 2016 15:57:56 +0000 (10:57 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 2 Mar 2016 15:57:58 +0000 (10:57 -0500)
When set, --newest-first causes the script to processes records in
descending order of edit_date, so that more recently edited/created
records are ingested first.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
pingest.pl [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 4c8753c..d1bb30f
@@ -36,6 +36,7 @@ my $skip_facets;  # Skip the facets reingest.
 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
+my $newest_first; # Process records in descending order of edit_date
 my $help;         # show help text
 
 GetOptions(
@@ -47,6 +48,7 @@ GetOptions(
     'skip-facets'    => \$skip_facets,
     'start-id=i'     => \$start_id,
     'end-id=i'       => \$end_id,
+    'newest-first'   => \$newest_first,
     'max-duration=i' => \$max_duration,
     'help'           => \$help
 );
@@ -75,6 +77,11 @@ sub help {
     --end-id
         Stop processing when this record ID is reached
 
+    --newest-first
+        During the initial bib record query, sort records by edit
+        date in descending order, so that records more recently
+        modified/created are processed before older records.
+
     --max-duration
         Stop processing after this many total seconds have passed.
 
@@ -96,12 +103,16 @@ if ($start_id && $end_id) {
     $where .= " AND id <= $end_id";
 }
 
+my $order_by = $newest_first ?
+    'ORDER BY edit_date DESC, id DESC' :
+    'ORDER BY id ASC';
+
 # "Gimme the keys!  I'll drive!"
 my $q = <<END_OF_Q;
 SELECT id
 FROM biblio.record_entry
 $where
-ORDER BY id ASC
+$order_by
 END_OF_Q
 
 # Stuffs needed for looping, tracking how many lists of records we