From 62e15689779533678f11664cb89db15cdb9fec86 Mon Sep 17 00:00:00 2001 From: dbs Date: Thu, 2 Jul 2009 17:06:10 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@557 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- tools/end_of_the_day.pl | 8 ++++- tools/reingest_uningested.pl | 72 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tools/reingest_uningested.pl diff --git a/tools/end_of_the_day.pl b/tools/end_of_the_day.pl index ae567e1aed..d3d84ca5d6 100644 --- a/tools/end_of_the_day.pl +++ b/tools/end_of_the_day.pl @@ -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 index 0000000000..9aa16a4ebf --- /dev/null +++ b/tools/reingest_uningested.pl @@ -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 = < 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); + } + } +} + -- 2.11.0