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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use Koha::Authority::MergeRequest;
29 use parent qw(Koha::Objects);
33 Koha::Authority::MergeRequests - Koha::Objects class for need_merge_authorities
37 use Koha::Authority::MergeRequests;
45 =head2 INSTANCE METHODS
49 =head3 reporting_tag_xml
51 my $xml = Koha::Authority::MergeRequests->reporting_tag_xml({
52 record => $record, tag => $tag,
57 sub reporting_tag_xml {
58 my ( $class, $params ) = @_;
59 return if !$params->{record} || !$params->{tag};
61 my $newrecord = MARC::Record->new;
62 $newrecord->encoding( 'UTF-8' );
63 my $reportfield = $params->{record}->field( $params->{tag} );
64 return if !$reportfield;
66 $newrecord->append_fields( $reportfield );
67 return $newrecord->as_xml(
68 C4::Context->preference('marcflavour') eq 'UNIMARC' ?
76 Koha::Authority::MergeRequests->cron_cleanup({
77 reset_hours => 24, remove_days => 90,
80 Removes all entries with status "done" older than remove_days.
81 Set all entries with status "in progress" back to 0 when the timestamp
82 is older than reset_hours.
83 Defaults: reset_hours = 1, remove_days = 30.
88 my ( $class_or_self, $params ) = @_;
89 my $reset_hours = $params->{reset_hours} || 1;
90 my $remove_days = $params->{remove_days} || 30;
91 my $parser = Koha::Database->new->schema->storage->datetime_parser;
93 my $dt = dt_from_string;
94 $dt->subtract( hours => $reset_hours );
95 $class_or_self->search({
97 timestamp => { '<' => $parser->format_datetime($dt) },
98 })->update({ done => 0 });
100 $dt = dt_from_string;
101 $dt->subtract( days => $remove_days );
102 $class_or_self->search({
104 timestamp => { '<' => $parser->format_datetime($dt) },
110 Returns name of corresponding DBIC resultset
115 return 'NeedMergeAuthority';
120 Returns name of corresponding Koha object class
125 return 'Koha::Authority::MergeRequest';
130 Marcel de Rooy (Rijksmuseum)
132 Koha Development Team