Bug 31306

Summary: Add Koha::Items->search_ordered method
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Nick Clemens <nick>
Severity: enhancement    
Priority: P5 - low CC: lucas, nick
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00
Bug Depends on:    
Bug Blocks: 36317, 31308, 31309, 31310, 31311, 31312, 31313, 31314, 31315, 31316, 31317, 31318, 31319, 31320, 31321, 32674    
Attachments: Bug 31306: Add search_ordered sub to order items with extra conditions
Bug 31306: Allow to pass params and attributes to search_ordered
Bug 31306: Add tests for search_ordered
Bug 31306: Add search_ordered sub to order items with extra conditions
Bug 31306: Allow to pass params and attributes to search_ordered
Bug 31306: Add tests for search_ordered
Bug 31306: Add search_ordered sub to order items with extra conditions
Bug 31306: Allow to pass params and attributes to search_ordered
Bug 31306: Add tests for search_ordered
Bug 31306: (QA follow-up) Add comments to test

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