Bug 28378: Elasticsearch - Add 264c to default copydate mappings (MARC21)
[koha-ffzg.git] / Koha / BiblioUtils.pm
index 88395a9..1ece4a8 100644 (file)
@@ -6,18 +6,18 @@ package Koha::BiblioUtils;
 #
 # This file is part of Koha.
 #
-# 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 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.
+# 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, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 =head1 NAME
 
@@ -32,12 +32,11 @@ the new thing that should be used.
 
 =cut
 
-use C4::Biblio; # EmbedItemsInMarcBiblio
+use C4::Biblio;
 use Koha::MetadataIterator;
 use Koha::Database;
 use Modern::Perl;
 
-use Data::Dumper; # TODO remove
 
 use base qw(Koha::MetadataRecord);
 
@@ -131,7 +130,12 @@ sub get_all_biblios_iterator {
     if ($options{slice}) {
         $slice_count = $options{slice}->{count};
         $slice_modulo = $options{slice}->{index};
-        $search_terms = \[ ' mod(biblionumber, ?) = ?', $slice_count, $slice_modulo];
+        $search_terms = \[ 'mod(biblionumber, ?) = ?', $slice_count, $slice_modulo ];
+    }
+
+    my $search_options = { columns => [qw/ biblionumber /] };
+    if ( $options{desc} ){
+        $search_options->{order_by}  = { -desc => 'biblionumber' };
     }
 
     my $database = Koha::Database->new();
@@ -139,7 +143,7 @@ sub get_all_biblios_iterator {
     my $rs =
       $schema->resultset('Biblio')->search(
         $search_terms,
-        { columns => [qw/ biblionumber /] } );
+        $search_options );
     my $next_func = sub {
         # Warn and skip bad records, otherwise we break the loop
         while (1) {