[Bug 19370] New: Add a helper function for translating order_by params into SQL::Abstract
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Bug ID: 19370 Summary: Add a helper function for translating order_by params into SQL::Abstract Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST api Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com It would be handy to have a helper function in Koha::REST::Plugin::Query generating the 'order_by' attribute out of the query params, to be used when listing objects on the REST api endpoints. -- 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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- 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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |19234 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19234 [Bug 19234] Add query parameters handling helpers -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67379 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67379&action=edit Bug 19370: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67380 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67380&action=edit Bug 19370: Add helper function for order_by attribute generation This patch introduces a helper function called 'dbic_merge_sorting' to Koha::REST::Plugin::Query. This simple function adds SQL::Abstract order_by attribute to the passed $filter hashref, as explained in the POD. It introduces a syntax for passing sorting params on the request to the REST api. The proposed syntax has been found in the wild, and is pretty trivial to parse/work with: GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3 As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it defaults to the DB engine default (usually asc). To test: - Apply this patches - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! And they make sense! :-P - Sign off :-D Sponsored-by: Camden County -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com, | |lari.taskula@jns.fi, | |martin.renvoize@ptfs-europe | |.com Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |19250 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19250 [Bug 19250] Add pagination to /acquisitions/vendors -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67379|0 |1 is obsolete| | --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67402 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67402&action=edit Bug 19370: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67380|0 |1 is obsolete| | --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67403 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67403&action=edit Bug 19370: Add helper function for order_by attribute generation This patch introduces a helper function called 'dbic_merge_sorting' to Koha::REST::Plugin::Query. This simple function adds SQL::Abstract order_by attribute to the passed $filter hashref, as explained in the POD. It introduces a syntax for passing sorting params on the request to the REST api. The proposed syntax has been found in the wild, and is pretty trivial to parse/work with: GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3 As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it defaults to the DB engine default (usually asc). To test: - Apply this patches - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! And they make sense! :-P - Sign off :-D Edit: renamed params to match DBIC terminology. My bad :-D (tcohen) Sponsored-by: Camden County -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67525 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67525&action=edit Bug 19369: (followup) Rename params for consitency with 19370 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #6 from Lari Taskula <lari.taskula@jns.fi> --- Is the patch "Bug 19369: (followup) Rename params for consitency with 19370" accidentally attached into this Bug? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #7 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Lari Taskula from comment #6)
Is the patch "Bug 19369: (followup) Rename params for consitency with 19370" accidentally attached into this Bug?
Indeed :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 67576 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67576&action=edit Bug 19370: Remove undefined variable warning 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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67525|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |19410 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19410 [Bug 19410] Koha::Objects needs a ->search_for_api method -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67402|0 |1 is obsolete| | --- Comment #9 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 67782 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67782&action=edit Bug 19370: Unit tests 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=19370 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67403|0 |1 is obsolete| | --- Comment #10 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 67783 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67783&action=edit Bug 19370: Add helper function for order_by attribute generation This patch introduces a helper function called 'dbic_merge_sorting' to Koha::REST::Plugin::Query. This simple function adds SQL::Abstract order_by attribute to the passed $filter hashref, as explained in the POD. It introduces a syntax for passing sorting params on the request to the REST api. The proposed syntax has been found in the wild, and is pretty trivial to parse/work with: GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3 As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it defaults to the DB engine default (usually asc). To test: - Apply this patches - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! And they make sense! :-P - Sign off :-D Edit: renamed params to match DBIC terminology. My bad :-D (tcohen) Sponsored-by: Camden County 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=19370 Lari Taskula <lari.taskula@jns.fi> 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=19370 Lari Taskula <lari.taskula@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67576|0 |1 is obsolete| | --- Comment #11 from Lari Taskula <lari.taskula@jns.fi> --- Created attachment 67784 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67784&action=edit Bug 19370: Remove undefined variable warning Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> 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=19370 --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69304 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69304&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch changes the _order_by definition so it's values are handled correctly by the Mojolicious::Plugin::OpenAPI plugin. Code is adjusted to expect a list instead of a (to-be-splitted) string. Tests are adjusted too. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69304|0 |1 is obsolete| | --- Comment #13 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69305 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69305&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch makes the helper handling _order_by params expect a list of values instead of a (to-be-splitted) string. The idea is that the OpenAPI plugin will take care of splitting pipe-delimited values if the spec is correctly defined. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69305|0 |1 is obsolete| | --- Comment #14 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69307 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69307&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch makes the helper handling _order_by params expect a list of values instead of a (to-be-splitted) string. The idea is that the OpenAPI plugin will take care of splitting pipe-delimited values if the spec is correctly defined. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|19250 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19250 [Bug 19250] Add pagination to /acquisitions/vendors -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69307|0 |1 is obsolete| | --- Comment #15 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69383 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69383&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch makes the helper handling _order_by params expect a list of values instead of a (to-be-splitted) string. The idea is that the OpenAPI plugin will take care of splitting pipe-delimited values if the spec is correctly defined. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! - Sign off :-D Edit: Removed rebasing leftover making the tests fail. 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=19370 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #69383|0 |1 is obsolete| | --- Comment #16 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 69384 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69384&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch makes the helper handling _order_by params expect a list of values instead of a (to-be-splitted) string. The idea is that the OpenAPI plugin will take care of splitting pipe-delimited values if the spec is correctly defined. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! - Sign off :-D Edit: Removed rebasing leftover making the tests fail. 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=19370 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=19370 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67782|0 |1 is obsolete| | Attachment #67783|0 |1 is obsolete| | Attachment #67784|0 |1 is obsolete| | Attachment #69384|0 |1 is obsolete| | --- Comment #17 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69391 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69391&action=edit Bug 19370: Unit tests 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=19370 --- Comment #18 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69392 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69392&action=edit Bug 19370: Add helper function for order_by attribute generation This patch introduces a helper function called 'dbic_merge_sorting' to Koha::REST::Plugin::Query. This simple function adds SQL::Abstract order_by attribute to the passed $filter hashref, as explained in the POD. It introduces a syntax for passing sorting params on the request to the REST api. The proposed syntax has been found in the wild, and is pretty trivial to parse/work with: GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3 As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it defaults to the DB engine default (usually asc). To test: - Apply this patches - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! And they make sense! :-P - Sign off :-D Edit: renamed params to match DBIC terminology. My bad :-D (tcohen) Sponsored-by: Camden County 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=19370 --- Comment #19 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69393 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69393&action=edit Bug 19370: Remove undefined variable warning Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> 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=19370 --- Comment #20 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 69394 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69394&action=edit Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values This patch makes the helper handling _order_by params expect a list of values instead of a (to-be-splitted) string. The idea is that the OpenAPI plugin will take care of splitting pipe-delimited values if the spec is correctly defined. Note: In the process I noticed + on the URL represents a space, so the helper function is updated to handle both + and %2B as ascending. To test: - Run: $ kshell k$ prove t/Koha/REST/Plugin/Query.t => SUCCESS: Tests pass! - Sign off :-D Edit: Removed rebasing leftover making the tests fail. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> 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=19370 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #21 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=19370 Bug 19370 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=19370 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com Status|Pushed to Master |RESOLVED Resolution|--- |FIXED --- Comment #22 from Nick Clemens <nick@bywatersolutions.com> --- Awesome work all! Enhancement, won't backport for for 17.11.01 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org