Bug 31569: Remove GetImportRecordsRange from list step
authorNick Clemens <nick@bywatersolutions.com>
Thu, 15 Sep 2022 13:47:07 +0000 (13:47 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 17 Oct 2022 11:14:56 +0000 (08:14 -0300)
This patch removes the use of GetImportRecordsRange from the step
of listing import batches to choose. It was only used for a count so is a simple
replacement

To test:
1 - Stage a number of files for import
2 - Import one of the files from tools
3 - Add to basket form a staged file
4 - Confirm staged baskets are listed, and imported basket is not

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
acqui/addorderiso2709.pl

index 712c63f..a235ca1 100755 (executable)
@@ -30,7 +30,7 @@ use Encode;
 use C4::Context;
 use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
-use C4::ImportBatch qw( GetImportRecordsRange GetImportRecordMarc GetImportRecordMatches SetImportRecordStatus SetMatchedBiblionumber SetImportBatchStatus GetImportBatch GetImportBatchRangeDesc GetNumberOfNonZ3950ImportBatches GetImportBatchOverlayAction GetImportBatchNoMatchAction GetImportBatchItemAction );
+use C4::ImportBatch qw( GetImportRecordMarc GetImportRecordMatches SetImportRecordStatus SetMatchedBiblionumber SetImportBatchStatus GetImportBatch GetImportBatchRangeDesc GetNumberOfNonZ3950ImportBatches GetImportBatchOverlayAction GetImportBatchNoMatchAction GetImportBatchItemAction );
 use C4::Matcher;
 use C4::Search qw( FindDuplicate );
 use C4::Biblio qw(
@@ -417,8 +417,11 @@ sub import_batches_list {
     foreach my $batch (@$batches) {
         if ( $batch->{'import_status'} =~ /^staged$|^reverted$/ && $batch->{'record_type'} eq 'biblio') {
             # check if there is at least 1 line still staged
-            my $stagedList=GetImportRecordsRange($batch->{'import_batch_id'}, undef, 1, $batch->{import_status}, { order_by_direction => 'ASC' });
-            if (scalar @$stagedList) {
+            my $import_records_count = Koha::Import::Records->search({
+                import_batch_id => $batch->{'import_batch_id'},
+                status          => $batch->{import_status}
+            })->count;
+            if ( $import_records_count ) {
                 push @list, {
                         import_batch_id => $batch->{'import_batch_id'},
                         num_records => $batch->{'num_records'},