Bugzilla – Attachment 138806 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.64 KB, created by
Jonathan Druart
on 2022-08-08 14:10:53 UTC
(
hide
)
Description:
Bug 31306: Add search_ordered sub to order items with extra conditions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-08 14:10:53 UTC
Size:
1.64 KB
patch
obsolete
>From 244beab87cb66469ec8673cfba44abe346ffd902 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 >--- > Koha/Items.pm | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 90b178a1cef..04db9654aae 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.25.1
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