1 package Koha::Authority::MergeRequests;
3 # Copyright Rijksmuseum 2017
5 # This file is part of Koha.
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.
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.
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>.
24 use Koha::Authority::MergeRequest;
26 use Koha::DateUtils qw( dt_from_string );
28 use parent qw(Koha::Objects);
32 Koha::Authority::MergeRequests - Koha::Objects class for need_merge_authorities
36 use Koha::Authority::MergeRequests;
48 Koha::Authority::MergeRequests->cron_cleanup({
49 reset_hours => 24, remove_days => 90,
52 Removes all entries with status "done" older than remove_days.
53 Set all entries with status "in progress" back to 0 when the timestamp
54 is older than reset_hours.
55 Defaults: reset_hours = 1, remove_days = 30.
60 my ( $class_or_self, $params ) = @_;
61 my $reset_hours = $params->{reset_hours} || 1;
62 my $remove_days = $params->{remove_days} || 30;
63 my $parser = Koha::Database->new->schema->storage->datetime_parser;
65 my $dt = dt_from_string;
66 $dt->subtract( hours => $reset_hours );
67 $class_or_self->search({
69 timestamp => { '<' => $parser->format_datetime($dt) },
70 })->update({ done => 0 });
73 $dt->subtract( days => $remove_days );
74 $class_or_self->search({
76 timestamp => { '<' => $parser->format_datetime($dt) },
82 Returns name of corresponding DBIC resultset
87 return 'NeedMergeAuthority';
92 Returns name of corresponding Koha object class
97 return 'Koha::Authority::MergeRequest';
102 Marcel de Rooy (Rijksmuseum)
104 Koha Development Team