From f7d9cab0b1dfcaf622c62711a7426645c2b9054c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 8 Jun 2023 13:11:32 +0000 Subject: [PATCH] Bug 33960: Add deleted option ot biblios endpoint This patch adds a 'deleted' parameter to the biblios endpoint. If this parameter is passed the API will return deleted biblios rather than current ones To test: 1 - Apply patch 2 - GET http://localhost:8081/api/v1/biblios 3 - Confirm you can search and page 4 - add 'deleted' param to query 5 - Confirm you get dleted biblios information 6 - Confirm searching and paging work as expected --- Koha/REST/V1/Biblios.pm | 5 ++++- api/v1/swagger/paths/biblios.yaml | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index eef084bc2c..4f198ef7b6 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::Biblios; +use Koha::Old::Biblios; use Koha::DateUtils; use Koha::Ratings; use Koha::RecordProcessor; @@ -802,7 +803,9 @@ sub list { push @prefetch, 'metadata' # don't prefetch metadata if not needed unless $c->req->headers->accept =~ m/application\/json/; - my $rs = Koha::Biblios->search( undef, { prefetch => \@prefetch }); + my $deleted = delete $c->param->{deleted}; + + my $rs = $deleted ? Koha::Old::Biblios->search() : Koha::Biblios->search( undef, { prefetch => \@prefetch } ); my $biblios = $c->objects->search_rs( $rs, [(sub{ $rs->api_query_fixer( $_[0], '', $_[1] ) })] ); return try { diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index d250237b68..22d4ab4223 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -67,6 +67,10 @@ - biblios summary: List biblios parameters: + - name: deleted + in: query + description: If information on deleted objects is requested + type: boolean - $ref: "../swagger.yaml#/parameters/page" - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/match" -- 2.30.2