From c1ada050c7839d9e35b602199de7536934025807 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Jun 2022 14:04:47 +0200 Subject: [PATCH] Bug 30877: use List::MoreUtils::uniq from recalls_to_pull.pl Test plan: Confirm that "Recalls to pull" is still working correctly --- recalls/recalls_to_pull.pl | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/recalls/recalls_to_pull.pl b/recalls/recalls_to_pull.pl index 06a14c5ea36..d320db49623 100755 --- a/recalls/recalls_to_pull.pl +++ b/recalls/recalls_to_pull.pl @@ -18,6 +18,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); +use List::MoreUtils qw( uniq ); + use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use Koha::BiblioFrameworks; @@ -60,7 +62,7 @@ if ( $op eq 'list' ) { my $biblio = Koha::Biblios->find($recall->biblio_id); my @this_bib_recalls = Koha::Recalls->search({ biblio_id => $recall->biblio_id, status => [ 'requested','overdue','in_transit' ] }, { order_by => { -asc => 'created_date' } })->as_list; my $recalls_count = scalar @this_bib_recalls; - my @unique_patrons = do { my %seen; grep { !$seen{$_->patron_id}++ } @this_bib_recalls }; + my @unique_patrons = uniq @this_bib_recalls ; my $patrons_count = scalar @unique_patrons; my $first_recall = $this_bib_recalls[0]; @@ -90,13 +92,6 @@ if ( $op eq 'list' ) { # don't push data if there are no items available for this recall # get unique values - my @unique_callnumbers = do { my %seen; grep { !$seen{$_}++ } @callnumbers }; - my @unique_copynumbers = do { my %seen; grep { !$seen{$_}++ } @copynumbers }; - my @unique_enumchrons = do { my %seen; grep { !$seen{$_}++ } @enumchrons }; - my @unique_itemtypes = do { my %seen; grep { !$seen{$_}++ } @itemtypes }; - my @unique_locations = do { my %seen; grep { !$seen{$_}++ } @locations }; - my @unique_libraries = do { my %seen; grep { !$seen{$_}++ } @libraries }; - push( @pull_list, { biblio => $recall->biblio, items_count => $items_count, @@ -104,12 +99,12 @@ if ( $op eq 'list' ) { patrons_count => $patrons_count, pull_count => $items_count <= $recalls_count ? $items_count : $recalls_count, first_recall => $first_recall, - callnumbers => \@unique_callnumbers, - copynumbers => \@unique_copynumbers, - enumchrons => \@unique_enumchrons, - itemtypes => \@unique_itemtypes, - locations => \@unique_locations, - libraries => \@unique_libraries, + callnumbers => [ uniq @callnumbers ], + copynumbers => [ uniq @copynumbers ], + enumchrons => [ uniq @enumchrons ], + itemtypes => [ uniq @itemtypes ], + locations => [ uniq @locations ], + libraries => [ uniq @libraries ], }); } } -- 2.25.1