Bugzilla – Attachment 31591 Details for
Bug 12919
Automate collecting all records added and deleted from the catalogue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12919 : Script to grab and email deleted records
Bug-12919--Script-to-grab-and-email-deleted-record.patch (text/plain), 4.42 KB, created by
Chris Cormack
on 2014-09-15 03:22:35 UTC
(
hide
)
Description:
Bug 12919 : Script to grab and email deleted records
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2014-09-15 03:22:35 UTC
Size:
4.42 KB
patch
obsolete
>From 648aa48183c425ebb02aa44363cc9ddf2462f857 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Mon, 15 Sep 2014 15:18:22 +1200 >Subject: [PATCH] Bug 12919 : Script to grab and email deleted records > >To test > >1/ Delete some records from your Koha (with isbns) > OR mark all items attached to a biblio as lost > >2/ if you are using koha from packages >run > >sudo koha-shell <kohainstancename> > >otherwise > >export PERL5LIB=/path/to/koha >export KOHA_CONF=/path/to/koha-conf.xml > >3/ run > >perl misc/cronjobs/newly_added_records --days 1 --address your@email.goes.here --lost --format isbn > >4/ Check your email and see if you got a list of isbn of deleted records >--- > misc/cronjobs/newly_deleted_records.pl | 94 ++++++++++++++++++++++++++++++++++ > 1 file changed, 94 insertions(+) > create mode 100755 misc/cronjobs/newly_deleted_records.pl > >diff --git a/misc/cronjobs/newly_deleted_records.pl b/misc/cronjobs/newly_deleted_records.pl >new file mode 100755 >index 0000000..54c9962 >--- /dev/null >+++ b/misc/cronjobs/newly_deleted_records.pl >@@ -0,0 +1,94 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 Catalyst IT >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+# This is script is to create a batch of MARC records that have been added to Koha in a set period >+# Then email the file to a designated email >+ >+use strict; >+use warnings; >+use DateTime; >+use C4::RecordExporter; >+ >+BEGIN { >+ >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/../kohalib.pl" }; >+} >+ >+use Getopt::Long; >+use Pod::Usage; >+ >+my ( $help, $days, $months, $verbose, $lost, @address, @not_itypes, $format, $filename ); >+GetOptions( >+ 'help|?' => \$help, >+ 'days=s' => \$days, >+ 'months=s' => \$months, >+ 'v' => \$verbose, >+ 'lost' => \$lost, >+ 'address=s' => \@address, >+ 'not_itype=s' => \@not_itypes, >+ 'format=s' => \$format, >+ 'filename=s' => \$filename, >+); >+ >+if ( $help or ( not $days and not $months ) or not @address or not $format ) { >+ print <<EOF >+This script creates an emails a batch of marc records that have been deleted >+from Koha in a set period of time >+ Parameters: >+ --help|-? This message >+ -v Verbose, output biblionumbers of records that can't be >+ parsed >+ --days TTT to define the age of marc records to export >+ --months TTT to define the age of marc records to export eg -months 1 >+ will export any created in the last calendar month >+ --address TTT to define the email address to send the file to. Can >+ be repeated. >+ --lost if this is set, also export biblio where all items are lost >+ --not_itype given an itype code, it will exclude these item types >+ from the export. Can be repeated. >+ --format 'marc': output the whole record as MARC, 'isbn': just >+ output text ISBN values. >+ --filename the filename (including extension) of the attachment. >+ May include %month% which is replaced with the current >+ month. >+ example : >+ export PERL5LIB=/path/to/koha;export KOHA_CONF=/etc/koha/koha-conf.xml;./newly_deleted_records --days 30 --address chrisc\@catalyst.net.nz --lost --format isbn >+EOF >+ ; >+ exit; >+} >+ >+$filename = $filename || 'Koha.' . ( $format eq 'isbn' ? 'csv' : 'mrc' ); >+my $month = lc( DateTime->now()->month_name() ); >+$filename =~ s/%month%/$month/g; >+ >+my $date = DateTime->now(); >+if ($days) { >+ $date->subtract( days => $days ); >+} >+elsif ($months) { >+ $date->set_day(1); >+ $date->subtract( months => $months ); >+} >+ >+export_and_mail_deleted( $date, \@address, $verbose, $lost, $format, >+ $filename, @not_itypes ); >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12919
:
31589
|
31590
|
31591
|
39260
|
39261
|
39262
|
39263
|
40505