From f68ce282515593689e99830e4d9cfad4eea491a6 Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Thu, 6 Jan 2022 14:48:36 +0100 Subject: [PATCH] Bug 29811: add timestamp option on authority record type According to the timestamp option for bibs record type I added the timestamp option for authority records. Timestamp is already present in database on field "modification_time" Test Plan : 1 - Be sure to have authority record type for easiest test create one 2 - Execute script export_records.pl in your koha/misc directory and choose a date (example yesterday if you just created an authority right now).(see export_records.pl -h for help) 3 - Timestamp option has no effect on authority record type 4 - Execute script again but choose the date of tomorrow for example 5 - Same result 6 - Apply this patch 7 - Play again steps 2 and 4 8 - On step 2 you will see only your authorities created today (because script show you authority has changes since the date you choose in option) and for step 4 you must see an empty file. Signed-off-by: Chris Cormack --- misc/export_records.pl | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/misc/export_records.pl b/misc/export_records.pl index 32658cb8c8..051657aa76 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -100,9 +100,6 @@ if ( $output_format eq 'csv' and not $csv_profile_id ) { pod2usage(q|Define a csv profile to export in CSV|); } -if ( $timestamp and $record_type ne 'bibs' ) { - pod2usage(q|--timestamp can only be used with biblios|); -} if ( $record_type ne 'bibs' and $record_type ne 'auths' ) { pod2usage(q|--record_type is not valid|); @@ -210,20 +207,33 @@ if ( $record_type eq 'bibs' ) { } } elsif ( $record_type eq 'auths' ) { - my $conditions = { - ( $starting_authid or $ending_authid ) + if ($timestamp) { + push @record_ids, $_->{authid} for @{ + $dbh->selectall_arrayref( + q| ( + SELECT authid + FROM auth_header + WHERE modification_time >= ? + ) |, { Slice => {} }, $timestamp + ); + }; + } else { + my $conditions = { + ( $starting_authid or $ending_authid ) ? ( authid => { ( $starting_authid ? ( '>=' => $starting_authid ) : () ), - ( $ending_authid ? ( '<=' => $ending_authid ) : () ), + ( $ending_authid ? ( '<=' => $ending_authid ) : () ), } - ) + ) : (), - ( $authtype ? ( authtypecode => $authtype ) : () ), - }; - # Koha::MetadataRecord::Authority is not a Koha::Object... - my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions ); - @record_ids = map { $_->authid } $authorities->all; + ( $authtype ? ( authtypecode => $authtype ) : () ), + }; + + # Koha::MetadataRecord::Authority is not a Koha::Object... + my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search($conditions); + @record_ids = map { $_->authid } $authorities->all; + } } @record_ids = uniq @record_ids; -- 2.30.2