From 44dbcc8c64934bba512fc5e459b8068d9a2d75b7 Mon Sep 17 00:00:00 2001 From: Mirko Tietgen Date: Sun, 28 Jun 2015 12:07:37 +0200 Subject: [PATCH] Bug 14469 - Script to delete Z39.50 results from the reservoir With every Z39.50 search, the reservoir gets filled with results. This script is supposed to delete all entries from z39.50 results from the reservoir. Test plan: - stage a mrc file for import - do a z3950 search - do a cataloguing search for something that will show results of both the staged mrc and the z3950 results, find results for both types in the reservoir part of the page - run this script - repeat the search, observe that results from mrc are still in the reservoir but those from z3950 are gone - check db for records from z3950 batches: SELECT import_record_id, import_batches.batch_type, import_batches.file_name FROM import_records JOIN import_batches USING (import_batch_id) WHERE batch_type LIKE 'z3950'; There should not be any results. - check db for batches from z3950: SELECT * FROM import_batches WHERE batch_type LIKE 'z3950'; There should not be any results. --- misc/cronjobs/clean_reservoir_z3950.pl | 69 ++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 misc/cronjobs/clean_reservoir_z3950.pl diff --git a/misc/cronjobs/clean_reservoir_z3950.pl b/misc/cronjobs/clean_reservoir_z3950.pl new file mode 100755 index 0000000..929ba26 --- /dev/null +++ b/misc/cronjobs/clean_reservoir_z3950.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2015 Mirko Tietgen, http://koha.abunchofthings.net +# +# 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 3 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, see . + +=head1 NAME + +clean_reservoir_z3950.pl - cron script to delete all z3950 results +from the reservoir + +=head1 SYNOPSIS + +./clean_reservoir_z3950.pl + +or, in crontab: +0 0 * * 0 clean_reservoir_z3950.pl + +=head1 DESCRIPTION + +With every Z39.50 search, the reservoir gets filled with results. +This script is supposed to delete all entries from z39.50 results +from the reservoir. + +=head1 OPTIONS + +No options. + +=cut + +use Modern::Perl; + +use C4::Context; +use C4::Log; + +cronlogaction(); + +my $dbh = C4::Context->dbh; + +# delete records from reservoir +my $query = "DELETE FROM import_records + WHERE import_batch_id IN ( + SELECT import_batch_id + FROM import_batches + WHERE batch_type LIKE 'z3950')"; + +my $sth = $dbh->prepare($query); +$sth->execute(); + +# delete empty batches +$query = "DELETE FROM import_batches + WHERE batch_type LIKE 'z3950'"; + +$sth = $dbh->prepare($query); +$sth->execute(); + -- 1.7.10.4