Bug 23763

Summary: Move pagination calculations to a subroutine
Product: Koha Reporter: Nick Clemens <nick>
Component: SearchingAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, david, fridolin.somers, jonathan.druart, kyle
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18008
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18030
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement moves duplicated code for the pagination of search results in the OPAC and staff interface into its own routine.
Version(s) released in:
21.05.00
Attachments: Bug 23763: Create a pagination_bar routine
Bug 23763: Make search on staff and opac use new routine
Bug 23763: Make search on staff and opac use new routine
Bug 23763: Create a pagination_bar routine
Bug 23763: Make search on staff and opac use new routine
Bug 23763: Create a pagination_bar routine
Bug 23763: Make search on staff and opac use new routine
Bug 23763: (QA follow-up) Add +x to Search.t file permissions
Bug 23763: Create a pagination_bar routine
Bug 23763: Make search on staff and opac use new routine

Description Nick Clemens 2019-10-07 13:55:32 UTC
Currently we duplicate some code used to build pagination parameters needed for page-numbers.inc, we should make this a subroutine and test it
Comment 1 Nick Clemens 2019-10-07 14:22:38 UTC
Created attachment 93824 [details] [review]
Bug 23763: Create a pagination_bar routine

To test:
prove -v t/Koha/SearchEngine/Search.t
Comment 2 Nick Clemens 2019-10-07 14:22:41 UTC
Created attachment 93825 [details] [review]
Bug 23763: Make search on staff and opac use new routine

To test:
1 - Apply patch
2 - Search on staff and opac side
3 - Confirm you can paginate results
4 - Confirm you see 10 pages on pagination if under page 10
5 - Confirm you see 20 pages in pagination if over page 10
6 - Confirm you can go to first or last page
Comment 3 David Nind 2020-02-22 18:37:40 UTC
I'm getting a fail on running the tests  - everything else seems okay:

root@bed39bee2cb5:koha(23763)$ prove -v t/Koha/SearchEngine/Search.t
t/Koha/SearchEngine/Search.t .. 
1..5
# Subtest: pagination_bar tests
    1..14
    ok 1 - We paginate all hits if less than max_result_window
    ok 2 - We have hits/hits_to_paginate pages
    ok 3 - We calculate current page by offset/results_per_page plus 1
    ok 4 - Previous page is current offset minus reults per page
    ok 5 - Next page is current offset plus reults per page
    ok 6 - Last page is pages minus 1 times reults per page
    ok 7 - If on first ten pages we only show 10 pages
    ok 8 - We paginate all hits if less than max_result_window
    ok 9 - We have hits/hits_to_paginate pages
    ok 10 - We calculate current page by offset/results_per_page plus 1
    ok 11 - Previous page is current offset minus reults per page
    ok 12 - Next page is current offset plus reults per page
    ok 13 - Last page is pages minus 1 times reults per page
    ok 14 - If past first ten pages we show 20 pages
ok 1 - pagination_bar tests
# Looks like you planned 5 tests but ran 1.
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 4/5 subtests 

Test Summary Report
-------------------
t/Koha/SearchEngine/Search.t (Wstat: 65280 Tests: 1 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 5 tests but ran 1.
Files=1, Tests=1,  1 wallclock secs ( 0.02 usr  0.00 sys +  0.86 cusr  0.07 csys =  0.95 CPU)
Result: FAIL
Comment 4 Nick Clemens 2020-12-23 14:35:41 UTC
Created attachment 114674 [details] [review]
Bug 23763: Make search on staff and opac use new routine

To test:
1 - Apply patch
2 - Search on staff and opac side
3 - Confirm you can paginate results
4 - Confirm you see 10 pages on pagination if under page 10
5 - Confirm you see 20 pages in pagination if over page 10
6 - Confirm you can go to first or last page
Comment 5 David Nind 2021-01-24 08:48:46 UTC
Created attachment 115720 [details] [review]
Bug 23763: Create a pagination_bar routine

To test:
prove -v t/Koha/SearchEngine/Search.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2021-01-24 08:48:49 UTC
Created attachment 115721 [details] [review]
Bug 23763: Make search on staff and opac use new routine

To test:
1 - Apply patch
2 - Search on staff and opac side
3 - Confirm you can paginate results
4 - Confirm you see 10 pages on pagination if under page 10
5 - Confirm you see 20 pages in pagination if over page 10
6 - Confirm you can go to first or last page

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Katrin Fischer 2021-02-07 13:15:45 UTC
Created attachment 116475 [details] [review]
Bug 23763: Create a pagination_bar routine

To test:
prove -v t/Koha/SearchEngine/Search.t

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Katrin Fischer 2021-02-07 13:15:49 UTC
Created attachment 116476 [details] [review]
Bug 23763: Make search on staff and opac use new routine

To test:
1 - Apply patch
2 - Search on staff and opac side
3 - Confirm you can paginate results
4 - Confirm you see 10 pages on pagination if under page 10
5 - Confirm you see 20 pages in pagination if over page 10
6 - Confirm you can go to first or last page

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Katrin Fischer 2021-02-07 13:15:52 UTC
Created attachment 116477 [details] [review]
Bug 23763: (QA follow-up) Add +x to Search.t file permissions

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Jonathan Druart 2021-02-08 15:44:30 UTC
Created attachment 116515 [details] [review]
Bug 23763: Create a pagination_bar routine

To test:
prove -v t/Koha/SearchEngine/Search.t

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

JD amended patch: perltidy
Comment 11 Jonathan Druart 2021-02-08 15:44:33 UTC
Created attachment 116516 [details] [review]
Bug 23763: Make search on staff and opac use new routine

To test:
1 - Apply patch
2 - Search on staff and opac side
3 - Confirm you can paginate results
4 - Confirm you see 10 pages on pagination if under page 10
5 - Confirm you see 20 pages in pagination if over page 10
6 - Confirm you can go to first or last page

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

JD amended patch: perltidy
Comment 12 Jonathan Druart 2021-02-08 15:50:07 UTC
It would have been good to have a bit more tests as we are not testing all the cases, neither the edge ones.
But much better than what we had!
Comment 13 Jonathan Druart 2021-02-08 16:04:37 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 14 Fridolin Somers 2021-02-12 14:13:02 UTC
Enhancement not pushed to 20.11.x