|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Copyright (C) 2015 Mirko Tietgen, http://koha.abunchofthings.net |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
=head1 NAME |
| 21 |
|
| 22 |
clean_reservoir_z3950.pl - cron script to delete all z3950 results |
| 23 |
from the reservoir |
| 24 |
|
| 25 |
=head1 SYNOPSIS |
| 26 |
|
| 27 |
./clean_reservoir_z3950.pl |
| 28 |
|
| 29 |
or, in crontab: |
| 30 |
0 0 * * 0 clean_reservoir_z3950.pl |
| 31 |
|
| 32 |
=head1 DESCRIPTION |
| 33 |
|
| 34 |
With every Z39.50 search, the reservoir gets filled with results. |
| 35 |
This script is supposed to delete all entries from z39.50 results |
| 36 |
from the reservoir. |
| 37 |
|
| 38 |
=head1 OPTIONS |
| 39 |
|
| 40 |
No options. |
| 41 |
|
| 42 |
=cut |
| 43 |
|
| 44 |
use Modern::Perl; |
| 45 |
|
| 46 |
use C4::Context; |
| 47 |
use C4::Log; |
| 48 |
|
| 49 |
cronlogaction(); |
| 50 |
|
| 51 |
my $dbh = C4::Context->dbh; |
| 52 |
|
| 53 |
# delete records from reservoir |
| 54 |
my $query = "DELETE FROM import_records |
| 55 |
WHERE import_batch_id IN ( |
| 56 |
SELECT import_batch_id |
| 57 |
FROM import_batches |
| 58 |
WHERE batch_type LIKE 'z3950')"; |
| 59 |
|
| 60 |
my $sth = $dbh->prepare($query); |
| 61 |
$sth->execute(); |
| 62 |
|
| 63 |
# delete empty batches |
| 64 |
$query = "DELETE FROM import_batches |
| 65 |
WHERE batch_type LIKE 'z3950'"; |
| 66 |
|
| 67 |
$sth = $dbh->prepare($query); |
| 68 |
$sth->execute(); |
| 69 |
|