LP1832897: Belt-and-suspenders for making sure max_items is set
authorMike Rylander <mrylander@gmail.com>
Tue, 3 Sep 2019 20:02:53 +0000 (16:02 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 4 Sep 2019 02:34:34 +0000 (19:34 -0700)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm

index 0b64841..9e9fa61 100644 (file)
@@ -176,12 +176,16 @@ sub add_carousel_from_bucket {
 
     $e->xact_begin;
 
+    # gather old entries to get a count and set max_items appropriately
+    my $entries = $e->search_container_biblio_record_entry_bucket_item({ bucket => $bucket_id });
+
     my $carousel = Fieldmapper::container::carousel->new;
     $carousel->name($carousel_name);
     $carousel->type(1); # manual
     $carousel->owner($e->requestor->ws_ou);
     $carousel->creator($e->requestor->id);
     $carousel->editor($e->requestor->id);
+    $carousel->max_items(scalar(@$entries));
     $e->create_container_carousel($carousel) or return $e->event;
 
     # and the bucket
@@ -199,7 +203,6 @@ sub add_carousel_from_bucket {
     $e->update_container_carousel($carousel) or return $e->event;
 
     # and fill it
-    my $entries = $e->search_container_biblio_record_entry_bucket_item({ bucket => $bucket_id });
     foreach my $entry (@$entries) {
         $entry->clear_id;
         $entry->bucket($bucket->id);