]> git.koha-community.org Git - koha.git/commit
Bug 33080: Allow pagination to be built from stashed values
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 3 Mar 2023 12:28:14 +0000 (09:28 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 10 Mar 2023 15:04:06 +0000 (12:04 -0300)
commitad83d2e07d3c2c28e962b1a2e8d04b6f25a4a868
tree63b8725c00a46be88075856b6ae2031ac616ac55
parent67a81d1328ad5f8720b3bf350ac494a0cd26f516
Bug 33080: Allow pagination to be built from stashed values

The way the old `objects.search` was build implied several totals were
calculated there, and passed to the `$c->add_pagination_headers` helper.

With the introduction of `objects.search_rs` and the ability of doing
things to the resultset afterwards, it felt like out of place to have
the pagination headers be implicitly set inside `objects.search_rs`.

This patch makes the search_rs stash some required values (from the original request) and
makes `add_pagination_headers` accept those values. This way other
callers can still build their own pagination values, while allowing this
simplified implementation.

Full-stack tests still pass, and the helper tests are moved to the
`db_dependent` section and are now more meaningful as well

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
   $ prove t/db_dependent/Koha/REST/Plugin/Pagination.t \
           t/db_dependent/api/v1/
=> SUCCESS: Tests pass! Nothing broken!
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/Plugin/Objects.pm
Koha/REST/Plugin/Pagination.pm
t/Koha/REST/Plugin/Pagination.t [deleted file]
t/db_dependent/Koha/REST/Plugin/Pagination.t [new file with mode: 0755]