[open-ils-commits] [GIT] Evergreen ILS branch master updated. 6b7381979d6bb2d7636325078f57705d06700c09

Evergreen Git git at git.evergreen-ils.org
Mon Jun 11 12:36:45 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  6b7381979d6bb2d7636325078f57705d06700c09 (commit)
      from  dafaf313a1b8ede49c5cb2f7b19a69f1e65db51b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6b7381979d6bb2d7636325078f57705d06700c09
Author: Steven Callender <stevecallender at esilibrary.com>
Date:   Thu Apr 19 09:47:46 2012 -0400

    Added a days_back parameter to authority_control_fields.pl in order to process bibs edited X amount of days ago.
    
    The days_back parameter can be used to easily run the script through cron nightly and have it process all newly created or newly added bib records. Ideally it would be ran once a day at nighttime prior to midnight using the --days_back 0 option.
    
    Signed-off-by: Steven Callender <stevecallender at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/support-scripts/authority_control_fields.pl.in b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
index 60c9d17..83f7db2 100755
--- a/Open-ILS/src/support-scripts/authority_control_fields.pl.in
+++ b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
@@ -33,6 +33,7 @@ use Pod::Usage qw/ pod2usage /;
 MARC::Charset->assume_unicode(1);
 
 my ($start_id, $end_id);
+my ($days_back);
 my $bootstrap = '@sysconfdir@/opensrf_core.xml';
 my @records;
 
@@ -44,12 +45,18 @@ my $result = GetOptions(
     'all', 'help',
     'start_id=i' => \$start_id,
     'end_id=i' => \$end_id,
+    'days_back=i' => \$days_back,
 );
 
 if (!$result or $options{help}) {
     pod2usage(0);
 }
 
+if ($start_id && $days_back) {
+    print "Can't use both start ID and days back!\n";
+    exit;
+}
+
 OpenSRF::System->bootstrap_client(config_file => $bootstrap);
 Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
 
@@ -72,6 +79,39 @@ if ($options{all}) {
 if ($start_id and $end_id) {
     @records = ($start_id .. $end_id);
 }
+
+if (defined $days_back) { 
+ at records=();
+
+# Grab DB information from local settings
+my $sc = OpenSRF::Utils::SettingsClient->new;
+my $db_driver = $sc->config_value( reporter => setup => database => 'driver' );
+my $db_host = $sc->config_value( reporter => setup => database => 'host' );
+my $db_port = $sc->config_value( reporter => setup => database => 'port' );
+my $db_name = $sc->config_value( reporter => setup => database => 'db' );
+if (!$db_name) {
+    $db_name = $sc->config_value( reporter => setup => database => 'name' );
+    print STDERR "WARN: <database><name> is a deprecated setting for database name. For future compatibility, you should use <database><db> instead." if $db_name;
+}
+my $db_user = $sc->config_value( reporter => setup => database => 'user' );
+my $db_pw = $sc->config_value( reporter => setup => database => 'pw' );
+
+die "Unable to retrieve database connection information from the settings server" unless ($db_driver && $db_host && $db_port && $db_name && $db_user);
+
+my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';port=' . $db_port;
+my $dbh = DBI->connect($dsn,$db_user,$db_pw, {AutoCommit => 1, pg_enable_utf8 => 1, RaiseError => 1}) or die "database connection error";
+
+# SQL Used to gather a list of ID's
+my $idstatement = $dbh->prepare("SELECT DISTINCT(id) AS id FROM biblio.record_entry where (date(create_date) = date(now()) or date(edit_date) = date((NOW() - '$days_back day'::interval)))");
+
+# Load the list of ID's into the records array
+$idstatement->execute();
+    while (my $ref = $idstatement->fetchrow_hashref()) {
+        my $id_ref = $ref->{"id"};   # the column name in our sql query is "id"
+        push(@records, $id_ref);
+    }
+}
+
 # print Dumper($undeleted, \@records);
 
 # Hash of controlled fields & subfields in bibliographic records, and their

-----------------------------------------------------------------------

Summary of changes:
 .../support-scripts/authority_control_fields.pl.in |   40 ++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list