Bugzilla – Attachment 67346 Details for
Bug 19196
Add pagination helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19196: Rename page and per_page
Bug-19196-Rename-page-and-perpage.patch (text/plain), 7.73 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-09-25 18:03:48 UTC
(
hide
)
Description:
Bug 19196: Rename page and per_page
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-09-25 18:03:48 UTC
Size:
7.73 KB
patch
obsolete
>From 40ab58cea9f24f4c10c48e2d71a7610d4eed59ae Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 25 Sep 2017 15:01:51 -0300 >Subject: [PATCH] Bug 19196: Rename page and per_page > >This patch just renames 'page' and 'per_page' params, for >'_page' and '_per_page' respectively. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/Plugin/Pagination.pm | 12 +++++------ > t/Koha/REST/Plugin/Pagination.t | 46 ++++++++++++++++++++--------------------- > 2 files changed, 29 insertions(+), 29 deletions(-) > >diff --git a/Koha/REST/Plugin/Pagination.pm b/Koha/REST/Plugin/Pagination.pm >index 8b09dd1..5f5b7eb 100644 >--- a/Koha/REST/Plugin/Pagination.pm >+++ b/Koha/REST/Plugin/Pagination.pm >@@ -42,8 +42,8 @@ sub register { > $c->add_pagination_headers({ > total => $patrons->count, > params => { >- page => ... >- per_page => ... >+ _page => ... >+ _per_page => ... > ... > } > }); >@@ -59,8 +59,8 @@ It also adds X-Total-Count, containing the total results count. > my ( $c, $args ) = @_; > > my $total = $args->{total}; >- my $req_page = $args->{params}->{page}; >- my $per_page = $args->{params}->{per_page}; >+ my $req_page = $args->{params}->{_page}; >+ my $per_page = $args->{params}->{_per_page}; > > my $pages = int $total / $per_page; > $pages++ >@@ -124,8 +124,8 @@ sub _build_link { > > my $params = $args->{params}; > >- $params->{page} = $args->{page}; >- $params->{per_page} = $args->{per_page}; >+ $params->{_page} = $args->{page}; >+ $params->{_per_page} = $args->{per_page}; > > my $link = '<' > . $c->req->url->clone->query( >diff --git a/t/Koha/REST/Plugin/Pagination.t b/t/Koha/REST/Plugin/Pagination.t >index 04d51e1..586b373 100644 >--- a/t/Koha/REST/Plugin/Pagination.t >+++ b/t/Koha/REST/Plugin/Pagination.t >@@ -32,19 +32,19 @@ get '/empty' => sub { > > get '/pagination_headers' => sub { > my $c = shift; >- $c->add_pagination_headers({ total => 10, params => { page => 2, per_page => 3, firstname => 'Jonathan' } }); >+ $c->add_pagination_headers({ total => 10, params => { _page => 2, _per_page => 3, firstname => 'Jonathan' } }); > $c->render( json => { ok => 1 }, status => 200 ); > }; > > get '/pagination_headers_first_page' => sub { > my $c = shift; >- $c->add_pagination_headers({ total => 10, params => { page => 1, per_page => 3, firstname => 'Jonathan' } }); >+ $c->add_pagination_headers({ total => 10, params => { _page => 1, _per_page => 3, firstname => 'Jonathan' } }); > $c->render( json => { ok => 1 }, status => 200 ); > }; > > get '/pagination_headers_last_page' => sub { > my $c = shift; >- $c->add_pagination_headers({ total => 10, params => { page => 4, per_page => 3, firstname => 'Jonathan' } }); >+ $c->add_pagination_headers({ total => 10, params => { _page => 4, _per_page => 3, firstname => 'Jonathan' } }); > $c->render( json => { ok => 1 }, status => 200 ); > }; > >@@ -67,44 +67,44 @@ subtest 'add_pagination_headers() tests' => sub { > $t->get_ok('/pagination_headers') > ->status_is( 200 ) > ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="prev",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=1.*>; rel="prev",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="prev",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="next",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=3.*>; rel="next",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="next",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=1.*>; rel="first",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=4.*>; rel="last"/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); > > $t->get_ok('/pagination_headers_first_page') > ->status_is( 200 ) > ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) > ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*>; rel="prev",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="next",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=2.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="next",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=2.*>; rel="next",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="next",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=1.*>; rel="first",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=4.*>; rel="last"/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); > > $t->get_ok('/pagination_headers_last_page') > ->status_is( 200 ) > ->header_is( 'X-Total-Count' => 10, 'X-Total-Count contains the passed value' ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="prev",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="prev",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=3.*>; rel="prev",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="prev",/ ) > ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*>; rel="next",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="first",/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=1.*>; rel="first",/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ ) >- ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_per_page=3.*>; rel="last"/ ) >+ ->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=4.*>; rel="last"/ ) > ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); > }; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19196
:
66599
|
66600
|
66601
|
66609
|
66610
|
66611
|
66656
|
66657
|
66658
|
66820
|
66821
|
66822
|
66988
|
66989
|
66990
|
67338
|
67339
|
67340
|
67346
|
67366
|
67367
|
67368
|
67369