diff --git a/Koha/Plugin/Fi/KohaSuomi/DI/AvailabilityController.pm b/Koha/Plugin/Fi/KohaSuomi/DI/AvailabilityController.pm index 8c79453..89966aa 100644 --- a/Koha/Plugin/Fi/KohaSuomi/DI/AvailabilityController.pm +++ b/Koha/Plugin/Fi/KohaSuomi/DI/AvailabilityController.pm @@ -95,6 +95,7 @@ sub biblio_hold { my $ignore_patron_holds = $c->validation->param('ignore_patron_holds'); my $limit_items = $c->validation->param('limit_items'); my $include_found_in_hold_queue = $c->validation->param('include_found_in_hold_queue'); + my $include_suspended_in_hold_queue = $c->validation->param('include_suspended_in_hold_queue'); return try { my $patron = Koha::Patrons->find($borrowernumber); @@ -106,6 +107,7 @@ sub biblio_hold { $params->{'query_pickup_locations'} = 1 if $query_pickup_locations; $params->{'ignore_patron_holds'} = 1 if $ignore_patron_holds; $params->{'include_found_in_hold_queue'} = 1 if $include_found_in_hold_queue; + $params->{'include_suspended_in_hold_queue'} = 1 if $include_suspended_in_hold_queue; $params->{'to_branch'} = $to_branch if $to_branch; $params->{'limit'} = $limit_items if $limit_items; @@ -140,6 +142,7 @@ sub biblio_search { my $biblionumber = $c->validation->param('biblio_id'); my $include_found_in_hold_queue = $c->validation->param('include_found_in_hold_queue'); + my $include_suspended_in_hold_queue = $c->validation->param('include_suspended_in_hold_queue'); return try { my $availability = undef; @@ -148,6 +151,7 @@ sub biblio_search { biblio => $biblio, }; $params->{'include_found_in_hold_queue'} = 1 if $include_found_in_hold_queue; + $params->{'include_suspended_in_hold_queue'} = 1 if $include_suspended_in_hold_queue; $availability = Koha::Plugin::Fi::KohaSuomi::DI::Koha::Availability::Search->biblio($params); return $c->render(status => 200, openapi => $availability->in_opac->to_api); } @@ -257,6 +261,7 @@ sub item_hold { my $query_pickup_locations = $c->validation->param('query_pickup_locations'); my $to_branch = $c->validation->param('library_id'); my $include_found_in_hold_queue = $c->validation->param('include_found_in_hold_queue'); + my $include_suspended_in_hold_queue = $c->validation->param('include_suspended_in_hold_queue'); return try { my $patron = Koha::Patrons->find($borrowernumber); @@ -272,6 +277,7 @@ sub item_hold { $params->{'to_branch'} = $to_branch; } $params->{'include_found_in_hold_queue'} = 1 if $include_found_in_hold_queue; + $params->{'include_suspended_in_hold_queue'} = 1 if $include_suspended_in_hold_queue; my $availability = undef; if (my $item = Koha::Items->find($itemnumber)) { diff --git a/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Biblio/Availability.pm b/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Biblio/Availability.pm index 29a4d00..1ce7be7 100644 --- a/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Biblio/Availability.pm +++ b/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Biblio/Availability.pm @@ -77,7 +77,10 @@ sub new { # Optionally include found holds in hold queue length calculation. $self->{'include_found_in_hold_queue'} = $params->{'include_found_in_hold_queue'}; - + + # Optionally include suspended holds in hold queue length calculation. + $self->{'include_suspended_in_hold_queue'} = $params->{'include_suspended_in_hold_queue'}; + if (exists $params->{'biblio'}) { unless (ref($params->{'biblio'}) eq 'Koha::Biblio') { Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::BadParameter->throw( @@ -199,6 +202,9 @@ sub get_hold_queue_length if (!$self->{'include_found_in_hold_queue'}) { $hold_params->{found} = undef; } + if (!$self->{'include_suspended_in_hold_queue'}) { + $hold_params->{suspend} = 0; + } return Koha::Holds->search($hold_params)->count; } diff --git a/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Item/Availability.pm b/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Item/Availability.pm index 7297aea..73e00fe 100644 --- a/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Item/Availability.pm +++ b/Koha/Plugin/Fi/KohaSuomi/DI/Koha/Item/Availability.pm @@ -73,6 +73,9 @@ sub new { # Optionally include found holds in hold queue length calculation. $self->{'include_found_in_hold_queue'} = $params->{'include_found_in_hold_queue'}; + # Optionally include suspended holds in hold queue length calculation. + $self->{'include_suspended_in_hold_queue'} = $params->{'include_suspended_in_hold_queue'}; + if (exists $params->{'item'}) { unless (ref($params->{'item'}) eq 'Koha::Item') { Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::BadParameter->throw( @@ -200,6 +203,9 @@ sub get_hold_queue_length if (!$self->{'include_found_in_hold_queue'}) { $hold_params->{found} = undef; } + if (!$self->{'include_suspended_in_hold_queue'}) { + $hold_params->{suspend} = 0; + } return Koha::Holds->search($hold_params)->count; } diff --git a/Koha/Plugin/Fi/KohaSuomi/DI/openapi.yaml b/Koha/Plugin/Fi/KohaSuomi/DI/openapi.yaml index 781b241..cb35784 100644 --- a/Koha/Plugin/Fi/KohaSuomi/DI/openapi.yaml +++ b/Koha/Plugin/Fi/KohaSuomi/DI/openapi.yaml @@ -160,6 +160,11 @@ paths: name: include_found_in_hold_queue required: false type: integer + - description: "Whether to include suspended holds in hold queue length. 1 = yes, 0 or no parameter = no." + in: query + name: include_suspended_in_hold_queue + required: false + type: integer produces: - application/json responses: @@ -217,6 +222,11 @@ paths: name: include_found_in_hold_queue required: false type: integer + - description: "Whether to include suspended holds in hold queue length. 1 = yes, 0 or no parameter = no." + in: query + name: include_suspended_in_hold_queue + required: false + type: integer produces: - application/json responses: @@ -358,6 +368,11 @@ paths: name: include_found_in_hold_queue required: false type: integer + - description: "Whether to include suspended holds in hold queue length. 1 = yes, 0 or no parameter = no." + in: query + name: include_suspended_in_hold_queue + required: false + type: integer produces: - application/json responses: diff --git a/Koha/Plugin/Fi/KohaSuomi/sample_requests.http b/Koha/Plugin/Fi/KohaSuomi/sample_requests.http index c2f3de3..9bb4b15 100644 --- a/Koha/Plugin/Fi/KohaSuomi/sample_requests.http +++ b/Koha/Plugin/Fi/KohaSuomi/sample_requests.http @@ -41,9 +41,19 @@ Authorization: Bearer {{token}} GET {{baseUrl}}/contrib/kohasuomi/availability/biblios/2/hold?patron_id=57&include_found_in_hold_queue=0 HTTP/1.1 Authorization: Bearer {{token}} +### +# @name hold_availability_suspended_included +GET {{baseUrl}}/contrib/kohasuomi/availability/biblios/2/hold?patron_id=57&include_suspended_in_hold_queue=1 HTTP/1.1 +Authorization: Bearer {{token}} + ### # @name item_hold_availability -GET {{baseUrl}}/contrib/kohasuomi/availability/items/30/hold?patron_id=57&include_found_in_hold_queue=1 HTTP/1.1 +GET {{baseUrl}}/contrib/kohasuomi/availability/items/154/hold?patron_id=57&include_found_in_hold_queue=1 HTTP/1.1 +Authorization: Bearer {{token}} + +### +# @name item_hold_availability_suspended_included +GET {{baseUrl}}/contrib/kohasuomi/availability/items/154/hold?patron_id=57&include_found_in_hold_queue=1&include_suspended_in_hold_queue=1 HTTP/1.1 Authorization: Bearer {{token}} ###