From: dbs Date: Fri, 17 Jul 2009 20:02:07 +0000 (+0000) Subject: Move daily scripts around, create a config directory for some good stuff like Z39... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a9284b2434ba37f0b7451bc02369a8e28e92ea95;p=contrib%2FConifer.git Move daily scripts around, create a config directory for some good stuff like Z39.50 servers git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@586 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/tools/circ_date_to_expire_date.pl b/tools/circ_date_to_expire_date.pl deleted file mode 100644 index 50492edb25..0000000000 --- a/tools/circ_date_to_expire_date.pl +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; - -# Evergreen sets due dates that are past the user's expiry date - -# Let's fix that after the fact, for now, by setting the due dates to the user's expiry date - -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, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0); - -GetOptions( - "bootstrap=s" => \$config, - "set_due_time" => \$set_due_time, -); - -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}); - -end_of_day($set_due_time); - -$dbh->disconnect; - -sub end_of_day { - my $set_due_time = shift; - - my $select_stmt = < au.expire_date - AND au.expire_date > NOW() - AND au.expire_date < NOW() + '2 years'::interval - AND au.home_ou IN (103, 110, 126) - ORDER BY au.expire_date -STMT - - my $update_stmt = < au.expire_date - AND au.expire_date > NOW() - AND au.expire_date < NOW() + '2 years'::interval - AND au.home_ou IN (103, 110, 126) - AND ac.checkin_time IS NULL -UPDATE - - - my $results = $dbh->selectall_arrayref($select_stmt); - print localtime() . " - found " . scalar(@$results) . " circulation transactions to update where due_date > expire_date\n"; - if ($set_due_time) { - my $stmt = $dbh->prepare($update_stmt); - my $updates = $stmt->execute(); - print "Updated $updates circulation transactions.\n"; - } -} - diff --git a/tools/config/z3950.xml b/tools/config/z3950.xml new file mode 100644 index 0000000000..578096b52d --- /dev/null +++ b/tools/config/z3950.xml @@ -0,0 +1,315 @@ + + biblios + + + + AMICUS + amicus.nlc-bnc.ca + 210 + NL + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + McGill + aleph.mcgill.ca + 210 + MUSE + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UChicago + ipac.lib.uchicago.edu + 210 + uofc + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + ULaval + ariane2.ulaval.ca + 2200 + unicorn + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UManitoba + lrpapp.cc.umanitoba.ca + 2200 + unicorn + + FI + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UMichigan + z3950.lib.umich.edu + 210 + miu101_pub + + FI + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UMontréal + atrium.bib.umontreal.ca + 210 + ADVANCE + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UofT + sirsi.library.utoronto.ca + 2200 + UNICORN + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + UWO + alpha.lib.uwo.ca + 210 + INNOPAC + + F + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + ‡biblios.net + z3950.biblios.net + 210 + bibliographic + + FI + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + loc + z3950.loc.gov + 7090 + Voyager + + FI + + + + usmarc + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + + zcat.oclc.org + 210 + OLUCWorldCat + + + 121 + 76 + 91 + 10036 + <code>4</code><format>6</format> + 81 + 10186 + 311 + 10011 + + + + + diff --git a/tools/daily-scripts/circ_date_to_expire_date.pl b/tools/daily-scripts/circ_date_to_expire_date.pl new file mode 100644 index 0000000000..50492edb25 --- /dev/null +++ b/tools/daily-scripts/circ_date_to_expire_date.pl @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w +use strict; +use warnings; + +# Evergreen sets due dates that are past the user's expiry date + +# Let's fix that after the fact, for now, by setting the due dates to the user's expiry date + +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, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0); + +GetOptions( + "bootstrap=s" => \$config, + "set_due_time" => \$set_due_time, +); + +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}); + +end_of_day($set_due_time); + +$dbh->disconnect; + +sub end_of_day { + my $set_due_time = shift; + + my $select_stmt = < au.expire_date + AND au.expire_date > NOW() + AND au.expire_date < NOW() + '2 years'::interval + AND au.home_ou IN (103, 110, 126) + ORDER BY au.expire_date +STMT + + my $update_stmt = < au.expire_date + AND au.expire_date > NOW() + AND au.expire_date < NOW() + '2 years'::interval + AND au.home_ou IN (103, 110, 126) + AND ac.checkin_time IS NULL +UPDATE + + + my $results = $dbh->selectall_arrayref($select_stmt); + print localtime() . " - found " . scalar(@$results) . " circulation transactions to update where due_date > expire_date\n"; + if ($set_due_time) { + my $stmt = $dbh->prepare($update_stmt); + my $updates = $stmt->execute(); + print "Updated $updates circulation transactions.\n"; + } +} + diff --git a/tools/daily-scripts/end_of_the_day.pl b/tools/daily-scripts/end_of_the_day.pl new file mode 100644 index 0000000000..fafe56da9a --- /dev/null +++ b/tools/daily-scripts/end_of_the_day.pl @@ -0,0 +1,104 @@ +#!/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. + +# We also found that editing the due date for a given item sets the corresponding +# due time to 00:00 - which isn't great, as that means that it is due the minute +# the day starts. So, for now, we'll set all daily / weekly loans or those loans +# that are due exactly at midnight to being due at 23:59:59 - the very last second +# of the day on which it is due. This probably meets our patrons' expectations a bit +# better. + +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, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0); + +GetOptions( + "bootstrap=s" => \$config, + "set_due_time" => \$set_due_time, +); + +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}); + +end_of_day($set_due_time); + +$dbh->disconnect; + +sub end_of_day { + my $set_due_time = shift; + + my $select_stmt = <selectcol_arrayref($select_stmt); + print localtime() . " - found " . scalar(@$results) . " circulation transactions to update:\n"; + foreach (@$results) { + print "\t$_\n"; + } + if ($set_due_time) { + my $stmt = $dbh->prepare($update_stmt); + my $updates = $stmt->execute(); + print "Updated $updates circulation transactions.\n"; + } +} diff --git a/tools/daily-scripts/reingest_uningested.pl b/tools/daily-scripts/reingest_uningested.pl new file mode 100644 index 0000000000..9aa16a4ebf --- /dev/null +++ b/tools/daily-scripts/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); + } + } +} + diff --git a/tools/delete_ill_books.pl b/tools/delete_ill_books.pl deleted file mode 100644 index b88b890898..0000000000 --- a/tools/delete_ill_books.pl +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/perl -w -use strict; - -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; -use File::Find; - -my ($config) = ('/openils/conf/opensrf_core.xml'); - -GetOptions( - "bootstrap=s" => \$config, -); - -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}); - -delete_racer_callnumbers(); - -$dbh->disconnect; - -sub delete_racer_callnumbers { - my $select_stmt = <selectcol_arrayref($select_stmt); - print localtime() . " - found " . scalar(@$results) . " RACER book call numbers to delete:\n"; - if (scalar(@$results)) { - foreach (@$results) { - print "\t$_\n"; - } - my $stmt = $dbh->prepare($delete_stmt); - my $updates = $stmt->execute(); - } -} - diff --git a/tools/end_of_the_day.pl b/tools/end_of_the_day.pl deleted file mode 100644 index fafe56da9a..0000000000 --- a/tools/end_of_the_day.pl +++ /dev/null @@ -1,104 +0,0 @@ -#!/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. - -# We also found that editing the due date for a given item sets the corresponding -# due time to 00:00 - which isn't great, as that means that it is due the minute -# the day starts. So, for now, we'll set all daily / weekly loans or those loans -# that are due exactly at midnight to being due at 23:59:59 - the very last second -# of the day on which it is due. This probably meets our patrons' expectations a bit -# better. - -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, $set_due_time) = ('/openils/conf/opensrf_core.xml', 0); - -GetOptions( - "bootstrap=s" => \$config, - "set_due_time" => \$set_due_time, -); - -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}); - -end_of_day($set_due_time); - -$dbh->disconnect; - -sub end_of_day { - my $set_due_time = shift; - - my $select_stmt = <selectcol_arrayref($select_stmt); - print localtime() . " - found " . scalar(@$results) . " circulation transactions to update:\n"; - foreach (@$results) { - print "\t$_\n"; - } - if ($set_due_time) { - my $stmt = $dbh->prepare($update_stmt); - my $updates = $stmt->execute(); - print "Updated $updates circulation transactions.\n"; - } -} diff --git a/tools/reingest_uningested.pl b/tools/reingest_uningested.pl deleted file mode 100644 index 9aa16a4ebf..0000000000 --- a/tools/reingest_uningested.pl +++ /dev/null @@ -1,72 +0,0 @@ -#!/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); - } - } -} -