Bug 33080: Adapt other use-cases
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 7 Mar 2023 11:26:51 +0000 (08:26 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 10 Mar 2023 15:04:07 +0000 (12:04 -0300)
This patch adapts the other controllers that rely on
add_pagination_headers outside of `objects.search`.

To test:
1. Apply this patchset
2. Run:
   $ ktd --shell
   $ prove t/db_dependent/api/v1/* \
           t/db_dependent/Koha/REST/Plugin/Objects.t \
           t/db_dependent/Koha/REST/Plugin/Pagination.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/REST/V1/Acquisitions/Orders.pm
Koha/REST/V1/ERM/EHoldings/Packages/EBSCO.pm
Koha/REST/V1/ERM/EHoldings/Resources/EBSCO.pm
Koha/REST/V1/ERM/EHoldings/Titles/EBSCO.pm

index ae9c1ba..d5a0fe7 100644 (file)
@@ -183,9 +183,11 @@ sub list {
 
         $c->add_pagination_headers(
             {
-                total      => ($orders->is_paged ? $orders->pager->total_entries : $orders->count),
-                base_total => $total,
-                params     => $args,
+                base_total   => $total,
+                page         => $reserved_params->{_page},
+                per_page     => $reserved_params->{_per_page},
+                query_params => $args,
+                total        => ( $orders->is_paged ? $orders->pager->total_entries : $orders->count ),
             }
         );
 
index defd5ea..ccdad76 100644 (file)
@@ -60,9 +60,11 @@ sub list {
 
         $c->add_pagination_headers(
             {
-                base_total => $base_total,
-                total      => $total,
-                params     => $args,
+                base_total   => $base_total,
+                page         => $args->{_page},
+                per_page     => $args->{_per_page},
+                query_params => $args,
+                total        => $total,
             }
         );
         return $c->render( status => 200, openapi => \@packages );
index abd4433..a404c03 100644 (file)
@@ -104,9 +104,11 @@ sub list {
         $total = 10000 if $total > 10000;
         $c->add_pagination_headers(
             {
-                base_total => $base_total,
-                total      => $total,
-                params     => $args,
+                base_total   => $base_total,
+                page         => $page,
+                per_page     => $per_page,
+                query_params => $args,
+                total        => $total,
             }
         );
         return $c->render( status => 200, openapi => \@resources );
index cf3c788..05c672c 100644 (file)
@@ -83,9 +83,11 @@ sub list {
 
         $c->add_pagination_headers(
             {
-                #base_total => $base_total,
-                total  => $total,
-                params => $args,
+               #base_total   => $base_total,
+                page         => $page,
+                per_page     => $per_page,
+                query_params => $args,
+                total        => $total,
             }
         );
         return $c->render( status => 200, openapi => \@titles );