Bugzilla – Attachment 138838 Details for
Bug 31306
Add Koha::Items->search_ordered method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31306: Add search_ordered sub to order items with extra conditions
Bug-31306-Add-searchordered-sub-to-order-items-wit.patch (text/plain), 1.69 KB, created by
Owen Leonard
on 2022-08-08 15:48:20 UTC
(
hide
)
Description:
Bug 31306: Add search_ordered sub to order items with extra conditions
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2022-08-08 15:48:20 UTC
Size:
1.69 KB
patch
obsolete
>From a6fa643f66a9a00748ab518c8205062dc507f3cf Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Mon, 18 Jul 2022 12:47:21 +0300 >Subject: [PATCH] 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> >--- > Koha/Items.pm | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 90b178a1ce..04db9654aa 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -398,6 +398,34 @@ sub apply_regex { > return $value; > } > >+=head3 search_ordered >+ >+ $items->search_ordered; >+ >+Search and sort items in a specific order, depending if serials are present or not >+ >+=cut >+ >+sub search_ordered { >+ my ($self) = @_; >+ >+ if ( $self->search({ select => ["enumchron IS NOT NULL"] }) ) { >+ return $self->search( {}, { order_by => 'enumchron' } ); >+ } else { >+ return $self->search( >+ {}, >+ { >+ order_by => [ >+ 'homebranch.branchname', >+ 'me.enumchron', >+ \"LPAD( me.copynumber, 8, '0' )", >+ {-desc => 'me.dateaccessioned'} >+ ], >+ join => ['homebranch'] >+ } >+ ); >+ } >+} > > =head2 Internal methods > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31306
:
138806
|
138807
|
138808
|
138838
|
138839
|
138840
|
138905
|
138906
|
138907
|
138908