[open-ils-commits] r557 - conifer/trunk/tools (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 2 13:06:12 EDT 2009
Author: dbs
Date: 2009-07-02 13:06:10 -0400 (Thu, 02 Jul 2009)
New Revision: 557
Added:
conifer/trunk/tools/reingest_uningested.pl
Modified:
conifer/trunk/tools/end_of_the_day.pl
Log:
New script: reingest_uningested.pl to ensure that records that didn't get ingested due to the mysterious simple_rec_sync problem do get ingested
Add a little description to the end_of_the_day script
Modified: conifer/trunk/tools/end_of_the_day.pl
===================================================================
--- conifer/trunk/tools/end_of_the_day.pl 2009-07-02 04:06:44 UTC (rev 556)
+++ conifer/trunk/tools/end_of_the_day.pl 2009-07-02 17:06:10 UTC (rev 557)
@@ -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::System;
use OpenSRF::AppSession;
use OpenSRF::Utils::SettingsClient;
-use File::Find;
my ($config, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0);
Added: conifer/trunk/tools/reingest_uningested.pl
===================================================================
--- conifer/trunk/tools/reingest_uningested.pl (rev 0)
+++ conifer/trunk/tools/reingest_uningested.pl 2009-07-02 17:06:10 UTC (rev 557)
@@ -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);
+ }
+ }
+}
+
More information about the open-ils-commits
mailing list