View | Details | Raw Unified | Return to bug 36120
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-9 / +18 lines)
Lines 383-407 sub pickup_locations { Link Here
383
    my ( $self, $params ) = @_;
383
    my ( $self, $params ) = @_;
384
384
385
    Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
385
    Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
386
      unless exists $params->{patron};
386
        unless exists $params->{patron};
387
387
388
    my $patron = $params->{patron};
388
    my $patron = $params->{patron};
389
389
390
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
390
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
391
    my @pickup_locations;
391
    my @pickup_locations;
392
    my $location_items;
392
    foreach my $item ( $self->items->as_list ) {
393
    foreach my $item ( $self->items->as_list ) {
393
        my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s",
394
        my $cache_key = sprintf "Pickup_locations:%s:%s:%s:%s:%s",
394
           $item->itype,$item->homebranch,$item->holdingbranch,$item->ccode || "",$patron->branchcode||"" ;
395
            $item->itype, $item->homebranch, $item->holdingbranch, $item->ccode || "", $patron->branchcode || "";
395
        my $item_pickup_locations = $memory_cache->get_from_cache( $cache_key );
396
        my $item_pickup_locations = $memory_cache->get_from_cache($cache_key);
396
        unless( $item_pickup_locations ){
397
        unless ($item_pickup_locations) {
397
          @{ $item_pickup_locations } = $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all;
398
            @{$item_pickup_locations} =
398
          $memory_cache->set_in_cache( $cache_key, $item_pickup_locations );
399
                $item->pickup_locations( { patron => $patron } )->_resultset->get_column('branchcode')->all;
400
            $memory_cache->set_in_cache( $cache_key, $item_pickup_locations );
401
        }
402
        push @pickup_locations, @{$item_pickup_locations};
403
        for my $location (@{$item_pickup_locations}) {
404
            push @{ $location_items->{$location} }, $item->itemnumber;
399
        }
405
        }
400
        push @pickup_locations, @{ $item_pickup_locations }
401
    }
406
    }
402
407
403
    return Koha::Libraries->search(
408
    my $resultSet =
404
        { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } );
409
        Koha::Libraries->search( { branchcode => { '-in' => \@pickup_locations } }, { order_by => ['branchname'] } );
410
411
    $resultSet->{_pickup_location_items} = $location_items;
412
413
    return $resultSet;
405
}
414
}
406
415
407
=head3 hidden_in_opac
416
=head3 hidden_in_opac
(-)a/Koha/REST/V1/Biblios.pm (+1 lines)
Lines 530-535 sub pickup_locations { Link Here
530
            my $pickup_locations = $c->objects->search($pl_set);
530
            my $pickup_locations = $c->objects->search($pl_set);
531
            @response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
531
            @response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
532
        }
532
        }
533
        @response = map { $_->{pickup_items} = $pl_set->{_pickup_location_items}->{ $_->{library_id} }; $_; } @response;
533
534
534
        return $c->render(
535
        return $c->render(
535
            status  => 200,
536
            status  => 200,
(-)a/api/v1/swagger/definitions/library.yaml (-1 / +7 lines)
Lines 104-109 properties: Link Here
104
  pickup_location:
104
  pickup_location:
105
    type: boolean
105
    type: boolean
106
    description: If the library can act as a pickup location
106
    description: If the library can act as a pickup location
107
  pickup_items:
108
    type:
109
      - array
110
      - 'null'
111
    description: Array of items available for pickup at this library if the library is marked as a pickup location
112
    items:
113
      type: integer
107
  public:
114
  public:
108
    type: boolean
115
    type: boolean
109
    description: If the library is visible to the public
116
    description: If the library is visible to the public
110
- 

Return to bug 36120