[Bug 19410] New: Koha::Objects needs a ->search_for_api method
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug ID: 19410 Summary: Koha::Objects needs a ->search_for_api method Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org We should extend Koha::Objects so searching can deal with squery parameters, specially handling pagination, results sorting, matching criteria, etc. This could be easily implemented using: - Bug 19196 (Pagination handling helpers) - Bug 19278 (Make REST api default page size configurable) - Bug 19234 (Query params handling helpers) - Bug 19369 (Query pagination to SQL::Abstract) - Bug 19370 (Query order by to SQL::Abstract) -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com, | |lari.taskula@jns.fi, | |martin.renvoize@ptfs-europe | |.com Depends on| |19196, 19278, 19234, 19369, | |19370 Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19196 [Bug 19196] Add pagination helpers https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19234 [Bug 19234] Add query parameters handling helpers https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19278 [Bug 19278] Add a configurable default page size for endpoints https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19369 [Bug 19369] Add a helper function for translating pagination params into SQL::Abstract https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 [Bug 19370] Add a helper function for translating order_by params into SQL::Abstract -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67613 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67613&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |In Discussion -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |18731 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18731 [Bug 18731] CRUD for acquisition orders -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67613|0 |1 is obsolete| | --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67731 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67731&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67732 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67732&action=edit Bug 19410: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67731|0 |1 is obsolete| | --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67750 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67750&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67732|0 |1 is obsolete| | --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67751 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67751&action=edit Bug 19410: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #6 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 67795 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67795&action=edit Bug 19410: (follow-up) Fix typo in POD -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67795|0 |1 is obsolete| | --- Comment #7 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 67798 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67798&action=edit Bug 19410: (follow-up) Fix typo in POD -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |julian.maurice@biblibre.com --- Comment #8 from Julian Maurice <julian.maurice@biblibre.com> --- It feels like search_for_api would fit better as a Mojo helper, given that it mostly call other helpers : $vendors = $c->search('Koha::Acquisition::Booksellers'); What do you think ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #9 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Julian Maurice from comment #8)
It feels like search_for_api would fit better as a Mojo helper, given that it mostly call other helpers :
$vendors = $c->search('Koha::Acquisition::Booksellers');
What do you think ?
my $plural_object = Koha::Acquisition::Booksellers->new; my $vendors = $c->object_search( $plural_object ); ? I'm not sure how to call $plural_object :-P -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #10 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69248 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69248&action=edit Bug 19410: Move search_for_api into a Mojo helper -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #11 from Julian Maurice <julian.maurice@biblibre.com> --- The last patch is a proposal for moving search_for_api out of Koha::Objects. Please tell me what you think. (In reply to Tomás Cohen Arazi from comment #9)
I'm not sure how to call $plural_object :-P
I don't know either, I called it $objects_set ... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67750|0 |1 is obsolete| | --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69253 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69253&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67751|0 |1 is obsolete| | --- Comment #13 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69254 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69254&action=edit Bug 19410: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67798|0 |1 is obsolete| | --- Comment #14 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69255 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69255&action=edit Bug 19410: (follow-up) Fix typo in POD Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69248|0 |1 is obsolete| | --- Comment #15 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69256 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69256&action=edit Bug 19410: Move search_for_api into a Mojo helper Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #16 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69257 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69257&action=edit Bug 19410: (QA followup) Move build_query_params_from_api into a helper This patch creates the 'build_query_params' helper, instead of the original function in Koha::Objects. Unit tests are removed for Koha::Objects::_build_query_params_from_api and written for the helper plugin. The objects.search helper gets a call to build_query_params added. Tests for it updated to match this behaviour change. To test: - Apply this patches - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t \ t/db_dependent/Koha/Objects.t \ t/db_dependent/Koha/REST/Plugin/Objects.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69253|0 |1 is obsolete| | --- Comment #17 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69258 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69258&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69254|0 |1 is obsolete| | --- Comment #18 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69259 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69259&action=edit Bug 19410: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69255|0 |1 is obsolete| | --- Comment #19 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69260 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69260&action=edit Bug 19410: (follow-up) Fix typo in POD Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69256|0 |1 is obsolete| | --- Comment #20 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69261 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69261&action=edit Bug 19410: Move search_for_api into a Mojo helper Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69257|0 |1 is obsolete| | --- Comment #21 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 69262 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69262&action=edit Bug 19410: (QA followup) Move build_query_params_from_api into a helper This patch creates the 'build_query_params' helper, instead of the original function in Koha::Objects. Unit tests are removed for Koha::Objects::_build_query_params_from_api and written for the helper plugin. The objects.search helper gets a call to build_query_params added. Tests for it updated to match this behaviour change. To test: - Apply this patches - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t \ t/db_dependent/Koha/Objects.t \ t/db_dependent/Koha/REST/Plugin/Objects.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|Architecture, internals, |REST api |and plumbing | QA Contact|testopia@bugs.koha-communit | |y.org | Summary|Koha::Objects needs a |Add a helper function for |->search_for_api method |generating object searches | |for the API -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|Small patch |Medium patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69258|0 |1 is obsolete| | --- Comment #22 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 69282 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69282&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69259|0 |1 is obsolete| | --- Comment #23 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 69283 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69283&action=edit Bug 19410: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69260|0 |1 is obsolete| | --- Comment #24 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 69284 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69284&action=edit Bug 19410: (follow-up) Fix typo in POD Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69261|0 |1 is obsolete| | --- Comment #25 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 69286 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69286&action=edit Bug 19410: Move search_for_api into a Mojo helper Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69262|0 |1 is obsolete| | --- Comment #26 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 69287 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69287&action=edit Bug 19410: (QA followup) Move build_query_params_from_api into a helper This patch creates the 'build_query_params' helper, instead of the original function in Koha::Objects. Unit tests are removed for Koha::Objects::_build_query_params_from_api and written for the helper plugin. The objects.search helper gets a call to build_query_params added. Tests for it updated to match this behaviour change. To test: - Apply this patches - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t \ t/db_dependent/Koha/Objects.t \ t/db_dependent/Koha/REST/Plugin/Objects.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |19686 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19686 [Bug 19686] objects.search helper needs a to_model param -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69282|0 |1 is obsolete| | --- Comment #27 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69385 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69385&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69283|0 |1 is obsolete| | --- Comment #28 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69386 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69386&action=edit Bug 19410: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69284|0 |1 is obsolete| | --- Comment #29 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69387 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69387&action=edit Bug 19410: (follow-up) Fix typo in POD Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69286|0 |1 is obsolete| | --- Comment #30 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69388 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69388&action=edit Bug 19410: Move search_for_api into a Mojo helper Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69287|0 |1 is obsolete| | --- Comment #31 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69389 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69389&action=edit Bug 19410: (QA followup) Move build_query_params_from_api into a helper This patch creates the 'build_query_params' helper, instead of the original function in Koha::Objects. Unit tests are removed for Koha::Objects::_build_query_params_from_api and written for the helper plugin. The objects.search helper gets a call to build_query_params added. Tests for it updated to match this behaviour change. To test: - Apply this patches - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t \ t/db_dependent/Koha/Objects.t \ t/db_dependent/Koha/REST/Plugin/Objects.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69385|0 |1 is obsolete| | Attachment #69386|0 |1 is obsolete| | Attachment #69387|0 |1 is obsolete| | Attachment #69388|0 |1 is obsolete| | Attachment #69389|0 |1 is obsolete| | --- Comment #32 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69397 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69397&action=edit Bug 19410: Add Koha::Objects->search_for_api Following the discussion about the best way to make things simpler for developing the REST api, I quote Lari's email: "As many other endpoint will have the exact same usage, by looking at your example, I would prefer to avoid writing parameter / pagination / sorting / header handling for each list operation in our API controllers. Do you think it's possible to centralize all of this e.g. by passing $c into a customized search sub? Perhaps in Koha::Objects? so instead we could have something like (ignore my bad choice of naming)...: sub list_vendors { my $c = shift->openapi->valid_input or return; my $args = $c->validation->output; my $vendors; return try { $vendors = Koha::Acquisition::Booksellers->api_list_search($c); return $c->render(status => 200, openapi => $vendors); } catch { ... } }" We all agreed we neeed something like that. Here's a possible implementation. I take advantage of the previously written Mojo helpers, that are fully covered by tests. I submit this early so anyone can take a look and gather ideas to make it even better. I'm already using it (effectively) for the /acquisitions/orders endpoint I'm writing on bug 18731. Thanks! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #33 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69398 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69398&action=edit Bug 19410: Unit tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #34 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69399 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69399&action=edit Bug 19410: (follow-up) Fix typo in POD Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #35 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69400 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69400&action=edit Bug 19410: Move search_for_api into a Mojo helper Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #36 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69401 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69401&action=edit Bug 19410: (QA followup) Move build_query_params_from_api into a helper This patch creates the 'build_query_params' helper, instead of the original function in Koha::Objects. Unit tests are removed for Koha::Objects::_build_query_params_from_api and written for the helper plugin. The objects.search helper gets a call to build_query_params added. Tests for it updated to match this behaviour change. To test: - Apply this patches - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t \ t/db_dependent/Koha/Objects.t \ t/db_dependent/Koha/REST/Plugin/Objects.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Lari Taskula <lari.taskula@jns.fi> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #37 from Kyle M Hall <kyle@bywatersolutions.com> --- I think rather than calling _to_model in each Controller, we should move that call to Koha::REST::Plugin::Objects, something like diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index eb3f951..163e364 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -45,7 +45,7 @@ sub register { 'objects.search' => sub { my ( $c, $objects_set ) = @_; - my $args = $c->validation->output; + my $args = $objects_set->_to_model( $c->validation->output ); my $attributes = {}; and change the extract to my ($params, $reserved_params) = $c->extract_reserved_params( $c->validation->output ); or something like that so the above 'patch' doesn't break it. We could add _to_model to a parent class of the modules in Koha::REST::V1 that essentially does nothing, and then each child class could override it with any customizations if necessary. That would simplify the code, and allow customization easily, if it is needed. If it isn't the class just won't have a _to_model method. This is probably better to implement in a followup bug report. That patches themselves appear to work great! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #38 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69545 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69545&action=edit Bug 19410: (followup) Add reserved params definitions This patch re-adds some parameters I left out during some rebasing tasks and ended up on a separate patchset (bug 18731). The introduced parameters definitions are only used on endpoint definitions that implement (at least) pagination. No need to test them here but easier adding them here than on a patch implementing a new enpoint, which would become a dependency for other endpoints. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |16330 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16330 [Bug 16330] REST API: add routes to add, update and delete patrons -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 --- Comment #39 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 69703 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69703&action=edit Bug 19410: (follow-up) Move build_query_params_from_api into a helper -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #40 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Pushed to master for 18.05, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug 19410 depends on bug 19234, which changed state. Bug 19234 Summary: Add query parameters handling helpers https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19234 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug 19410 depends on bug 19369, which changed state. Bug 19369 Summary: Add a helper function for translating pagination params into SQL::Abstract https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19369 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug 19410 depends on bug 19278, which changed state. Bug 19278 Summary: Add a configurable default page size for endpoints https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19278 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug 19410 depends on bug 19370, which changed state. Bug 19370 Summary: Add a helper function for translating order_by params into SQL::Abstract https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED CC| |nick@bywatersolutions.com Resolution|--- |FIXED --- Comment #41 from Nick Clemens <nick@bywatersolutions.com> --- Awesome work all! Enhancement, not backporting for 17.11.01 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Bug 19410 depends on bug 19196, which changed state. Bug 19196 Summary: Add pagination helpers https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19196 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |25570 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25570 [Bug 25570] Listing requests should be paginated by default -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org