View | Details | Raw Unified | Return to bug 14469
Collapse All | Expand All

(-)a/misc/cronjobs/clean_reservoir_z3950.pl (-1 / +70 lines)
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::Circulation;
47
use C4::Context;
48
use C4::Log;
49
50
cronlogaction();
51
52
my $dbh = C4::Context->dbh;
53
54
# delete records from reservoir
55
my $query = "DELETE FROM import_records
56
             WHERE import_batch_id IN (
57
                 SELECT import_batch_id
58
                 FROM import_batches
59
                 WHERE batch_type LIKE 'z3950')";
60
61
my $sth = $dbh->prepare($query);
62
$sth->execute();
63
64
# delete empty batches
65
$query = "DELETE FROM import_batches
66
          WHERE batch_type LIKE 'z3950'";
67
68
$sth = $dbh->prepare($query);
69
$sth->execute();
70

Return to bug 14469