Update to include another new RACER book feature/tools_daily_scripts_2_4
authorDan Scott <dscott@laurentian.ca>
Mon, 7 Dec 2015 17:46:05 +0000 (12:46 -0500)
committerDan Scott <dscott@laurentian.ca>
Mon, 7 Dec 2015 17:46:05 +0000 (12:46 -0500)
A RACER book was deleted, and a new one took its place. Thus we need to
update the script so that the copies & call numbers will be trimmed from
that book too.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/daily-scripts/delete_ill_books.pl [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 28187e6..3df0864
@@ -13,7 +13,7 @@ use File::Find;
 my ($config) = ('/openils/conf/opensrf_core.xml');
 
 GetOptions(
-       "bootstrap=s"   => \$config,
+        "bootstrap=s"   => \$config,
 );
 
 OpenSRF::System->bootstrap_client( config_file => $config );
@@ -35,80 +35,82 @@ delete_racer_callnumbers();
 $dbh->disconnect;
 
 sub delete_racer_callnumbers {
-       my $select_stmt = <<SELECT;
-               SELECT acn.id
-               FROM asset.call_number acn
-               INNER JOIN asset.copy ac ON ac.call_number = acn.id
-               INNER JOIN action.circulation acirc ON ac.id = acirc.target_copy
-               AND acn.record IN (
-                       SELECT bre.id
-                       FROM biblio.record_entry bre
-                       WHERE bre.id IN (
-                               2237519,
-                               2239801,
-                               2239798,
-                               2239797,
-                               2239799,
-                               2239800,
-                               2247576
+        my $select_stmt = <<SELECT;
+                SELECT acn.id
+                FROM asset.call_number acn
+                INNER JOIN asset.copy ac ON ac.call_number = acn.id
+                INNER JOIN action.circulation acirc ON ac.id = acirc.target_copy
+                AND acn.record IN (
+                        SELECT bre.id
+                        FROM biblio.record_entry bre
+                        WHERE bre.id IN (
+                                2237519,
+                                2239801,
+                                2239798,
+                                2239797,
+                                2239799,
+                                2239800,
+                                2247576,
+                                2900325
                         )
-                       AND bre.deleted IS FALSE
-               ) AND acirc.checkin_time IS NOT NULL
-               AND acirc.id NOT IN (
-                       SELECT id 
-                       FROM money.open_billable_xact_summary
-               ) AND acn.deleted IS FALSE
-               AND ac.status NOT IN (1, 7);
+                        AND bre.deleted IS FALSE
+                ) AND acirc.checkin_time IS NOT NULL
+                AND acirc.id NOT IN (
+                        SELECT id
+                        FROM money.open_billable_xact_summary
+                ) AND acn.deleted IS FALSE
+                AND ac.status NOT IN (1, 7)
 
 SELECT
 
-       my $delete_stmt = <<DELETE;
-               DELETE FROM asset.call_number acn
-               USING  asset.copy ac 
-               INNER JOIN action.circulation acirc ON ac.id = acirc.target_copy
-               WHERE acn.id = ac.call_number 
-               AND acn.record IN (
-                       SELECT bre.id
-                       FROM biblio.record_entry bre
-                       WHERE bre.id IN (
-                               2237519,
-                               2239801,
-                               2239798,
-                               2239797,
-                               2239799,
-                               2239800,
-                               2247576
+        my $delete_stmt = <<DELETE;
+                DELETE FROM asset.call_number acn
+                USING  asset.copy ac
+                INNER JOIN action.circulation acirc ON ac.id = acirc.target_copy
+                WHERE acn.id = ac.call_number
+                AND acn.record IN (
+                        SELECT bre.id
+                        FROM biblio.record_entry bre
+                        WHERE bre.id IN (
+                                2237519,
+                                2239801,
+                                2239798,
+                                2239797,
+                                2239799,
+                                2239800,
+                                2247576,
+                                2900325
                         )
-                       AND bre.deleted IS FALSE
-               ) AND acirc.checkin_time IS NOT NULL
-               AND acirc.id NOT IN (
-                       SELECT id 
-                       FROM money.open_billable_xact_summary
-               ) AND acn.deleted IS FALSE
-               AND ac.status NOT IN (1, 7);
+                        AND bre.deleted IS FALSE
+                ) AND acirc.checkin_time IS NOT NULL
+                AND acirc.id NOT IN (
+                        SELECT id
+                        FROM money.open_billable_xact_summary
+                ) AND acn.deleted IS FALSE
+                AND ac.status NOT IN (1, 7)
 DELETE
 
     my $delete_copies_stmt = <<DELETECOPIES;
     UPDATE asset.copy
       SET deleted = TRUE FROM asset.call_number acn
       WHERE asset.copy.call_number = acn.id
-        AND acn.record IN (2237519,2239801,2239798,2239797,2239799,2239800,2247576)
+        AND acn.record IN (2237519,2239801,2239798,2239797,2239799,2239800,2247576,2900325)
         AND acn.deleted IS TRUE
         AND asset.copy.deleted IS FALSE
         AND asset.copy.circ_lib = 103
         AND asset.copy.status NOT IN (1, 7);
 DELETECOPIES
 
-       my $results = $dbh->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();
-               $stmt = $dbh->prepare($delete_copies_stmt);
-               $updates = $stmt->execute();
-       }
+        my $results = $dbh->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();
+                $stmt = $dbh->prepare($delete_copies_stmt);
+                $updates = $stmt->execute();
+        }
 }