Bug 23763 - Move pagination calculations to a subroutine
Summary: Move pagination calculations to a subroutine
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-07 13:55 UTC by Nick Clemens
Modified: 2021-06-14 21:35 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
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 (7.21 KB, patch)
2019-10-07 14:22 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23763: Make search on staff and opac use new routine (9.44 KB, patch)
2019-10-07 14:22 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23763: Make search on staff and opac use new routine (9.79 KB, patch)
2020-12-23 14:35 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 23763: Create a pagination_bar routine (7.25 KB, patch)
2021-01-24 08:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 23763: Make search on staff and opac use new routine (9.83 KB, patch)
2021-01-24 08:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 23763: Create a pagination_bar routine (7.31 KB, patch)
2021-02-07 13:15 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23763: Make search on staff and opac use new routine (9.89 KB, patch)
2021-02-07 13:15 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23763: (QA follow-up) Add +x to Search.t file permissions (555 bytes, patch)
2021-02-07 13:15 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23763: Create a pagination_bar routine (7.87 KB, patch)
2021-02-08 15:44 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 23763: Make search on staff and opac use new routine (10.24 KB, patch)
2021-02-08 15:44 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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