Bug 31306 - Add Koha::Items->search_ordered method
Summary: Add Koha::Items->search_ordered method
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Nick Clemens
URL:
Keywords:
Depends on:
Blocks: 31310 31314 31317 31318 31320 31308 31309 31311 31312 31313 31315 31316 31319 31321
  Show dependency treegraph
 
Reported: 2022-08-08 14:07 UTC by Jonathan Druart
Modified: 2022-09-30 22:42 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00


Attachments
Bug 31306: Add search_ordered sub to order items with extra conditions (1.64 KB, patch)
2022-08-08 14:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31306: Allow to pass params and attributes to search_ordered (1.30 KB, patch)
2022-08-08 14:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31306: Add tests for search_ordered (6.68 KB, patch)
2022-08-08 14:11 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31306: Add search_ordered sub to order items with extra conditions (1.69 KB, patch)
2022-08-08 15:48 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 31306: Allow to pass params and attributes to search_ordered (1.35 KB, patch)
2022-08-08 15:48 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 31306: Add tests for search_ordered (6.73 KB, patch)
2022-08-08 15:48 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 31306: Add search_ordered sub to order items with extra conditions (1.69 KB, patch)
2022-08-09 12:58 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31306: Allow to pass params and attributes to search_ordered (1.35 KB, patch)
2022-08-09 12:58 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31306: Add tests for search_ordered (6.73 KB, patch)
2022-08-09 12:58 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 31306: (QA follow-up) Add comments to test (3.82 KB, patch)
2022-08-09 12:58 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2022-08-08 14:07:39 UTC
On bug 27272 we are going to replace C4::Items::GetItemsInfo with Koha::Items methods, but we need to keep the existing behaviour that is:
Order by publisheddate, enumchron for searisl, or by homebranch.branchname, enumchron, LPAD( copynumber, 8, '0' ), desc dateaccessioned
Comment 1 Jonathan Druart 2022-08-08 14:10:53 UTC
Created attachment 138806 [details] [review]
Bug 31306: Add search_ordered sub to order items with extra conditions

Commit message from JD:
On bug 27272 we are going to replace C4::Items::GetItemsInfo with Koha::Items methods, but we need to keep the existing behaviour that is:
Order by publisheddate, enumchron for searisl, or by homebranch.branchname, enumchron, LPAD( copynumber, 8, '0' ), desc dateaccessioned

Test plan:
Confirm that the code from the new method makes sense
Run t/db_dependent/Koha/Items.t
Comment 2 Jonathan Druart 2022-08-08 14:10:57 UTC
Created attachment 138807 [details] [review]
Bug 31306: Allow to pass params and attributes to search_ordered
Comment 3 Jonathan Druart 2022-08-08 14:11:00 UTC
Created attachment 138808 [details] [review]
Bug 31306: Add tests for search_ordered
Comment 4 Owen Leonard 2022-08-08 15:48:20 UTC
Created attachment 138838 [details] [review]
Bug 31306: Add search_ordered sub to order items with extra conditions

Commit message from JD:

On bug 27272 we are going to replace C4::Items::GetItemsInfo with Koha::Items
methods, but we need to keep the existing behaviour that is:

Order by publisheddate, enumchron for searisl, or by homebranch.branchname,
enumchron, LPAD( copynumber, 8, '0' ), desc dateaccessioned

Test plan:
Confirm that the code from the new method makes sense
Run t/db_dependent/Koha/Items.t

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Owen Leonard 2022-08-08 15:48:24 UTC
Created attachment 138839 [details] [review]
Bug 31306: Allow to pass params and attributes to search_ordered

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Owen Leonard 2022-08-08 15:48:28 UTC
Created attachment 138840 [details] [review]
Bug 31306: Add tests for search_ordered

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 7 Nick Clemens 2022-08-09 12:18:40 UTC
You are deciding which way to sort based on:
$self->search({ select => ["enumchron IS NOT NULL"]

The original routine based it upon:
$serial
Which was a join between items->serialitems->serial

I do not believe testing for enumchron is the same result - many libraries use the enumchron for other purposes. Probably a count of serial items would suffice?
Comment 8 Jonathan Druart 2022-08-09 12:32:06 UTC
Nick, have a look at the squashed version :)
There is a (unadvertised) change that does what I think is correct in the second patch.
Comment 9 Nick Clemens 2022-08-09 12:58:43 UTC
Created attachment 138905 [details] [review]
Bug 31306: Add search_ordered sub to order items with extra conditions

Commit message from JD:

On bug 27272 we are going to replace C4::Items::GetItemsInfo with Koha::Items
methods, but we need to keep the existing behaviour that is:

Order by publisheddate, enumchron for searisl, or by homebranch.branchname,
enumchron, LPAD( copynumber, 8, '0' ), desc dateaccessioned

Test plan:
Confirm that the code from the new method makes sense
Run t/db_dependent/Koha/Items.t

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 10 Nick Clemens 2022-08-09 12:58:46 UTC
Created attachment 138906 [details] [review]
Bug 31306: Allow to pass params and attributes to search_ordered

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 11 Nick Clemens 2022-08-09 12:58:49 UTC
Created attachment 138907 [details] [review]
Bug 31306: Add tests for search_ordered

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 12 Nick Clemens 2022-08-09 12:58:53 UTC
Created attachment 138908 [details] [review]
Bug 31306: (QA follow-up) Add comments to test
Comment 13 Tomás Cohen Arazi 2022-08-09 15:06:14 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 14 Lucas Gass 2022-09-30 22:42:12 UTC
Enhancement will not be backported to 22.05.x series