New script: reingest_uningested.pl to ensure that records that didn't get ingested...
authordbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 2 Jul 2009 17:06:10 +0000 (17:06 +0000)
committerdbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 2 Jul 2009 17:06:10 +0000 (17:06 +0000)
Add a little description to the end_of_the_day script

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@557 6d9bc8c9-1ec2-4278-b937-99fde70a366f

tools/end_of_the_day.pl
tools/reingest_uningested.pl [new file with mode: 0644]

index ae567e1..d3d84ca 100644 (file)
@@ -1,5 +1,12 @@
 #!/usr/bin/perl -w
 
+# Sets the due time of items with a given loan period for a given library to 23:59:59
+
+# This is a temporary workaround for Evergreen's assumption that the
+# fine generating script will only run once a day, to avoid dinging a patron
+# with an overdue charge at 48 hours + 5 minutes rather than at the end of the
+# day that 48 hours falls on.
+
 use DBI;
 use Getopt::Long;
 use OpenSRF::EX qw/:try/;
@@ -7,7 +14,6 @@ use OpenSRF::Utils qw/:daemon/;
 use OpenSRF::System;
 use OpenSRF::AppSession;
 use OpenSRF::Utils::SettingsClient;
-use File::Find;
 
 my ($config, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0);
 
diff --git a/tools/reingest_uningested.pl b/tools/reingest_uningested.pl
new file mode 100644 (file)
index 0000000..9aa16a4
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+# Reingest biblio.record_entry records that didn't get ingested due to the simple_rec_sync bug
+# Ingested records are expected to have an entry in the keyword index
+# Might want to build a variation on this that reingests edited records on a nightly basis
+
+use DBI;
+use Getopt::Long;
+use OpenSRF::EX qw/:try/;
+use OpenSRF::Utils qw/:daemon/;
+use OpenSRF::System;
+use OpenSRF::AppSession;
+use OpenSRF::Utils::SettingsClient;
+
+my ($config, $reingest) = ('/openils/conf/opensrf_core.xml', 0);
+
+GetOptions(
+       "bootstrap=s"   => \$config,
+       "reingest"      => \$reingest,
+);
+
+OpenSRF::System->bootstrap_client( config_file => $config );
+
+my $sc = OpenSRF::Utils::SettingsClient->new;
+my $db_driver = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => 'driver' );
+my $db_host = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'host' );
+my $db_port = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'port' );
+my $db_name = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'db' );
+my $db_user = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'user' );
+my $db_pw = $sc->config_value( apps => 'open-ils.storage' => app_settings => databases => database => 'pw' );
+
+my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';port=' . $db_port;
+
+my $dbh = DBI->connect($dsn,$db_user,$db_pw, {pg_enable_utf8 => 1, RaiseError => 1});
+
+reingest_empty_records($reingest);
+
+$dbh->disconnect;
+
+sub reingest_empty_records {
+       my $select_stmt = <<STMT;
+               SELECT bre.id
+               FROM biblio.record_entry bre
+               WHERE deleted IS FALSE
+               AND bre.id > 0
+               EXCEPT
+               SELECT mrd.source
+               FROM metabib.keyword_field_entry mrd
+STMT
+
+       my $results = $dbh->selectcol_arrayref($select_stmt);
+       print localtime() . " - found " . scalar(@$results) . " records to reingest\n";
+       foreach (@$results) {
+               print "\t$_\n";
+       }
+       if ($reingest) {
+
+               foreach (@$results) {
+                       my $r = OpenSRF::AppSession
+                               ->create( 'open-ils.ingest' )
+                               ->request( 'open-ils.ingest.full.biblio.record' => $_ );
+
+                       while (!$r->complete) { $r->recv };
+
+                       # Sleep for 10 seconds between each request to prevent blocking
+                       sleep(10);
+               }
+       }
+}
+