Bugzilla – Attachment 151923 Details for
Bug 33493
Add a filter relationship for branchtransfers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33493: Add a filter relationship for branchtransfers
Bug-33493-Add-a-filter-relationship-for-branchtran.patch (text/plain), 2.24 KB, created by
Nick Clemens (kidclamp)
on 2023-06-01 12:27:37 UTC
(
hide
)
Description:
Bug 33493: Add a filter relationship for branchtransfers
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-06-01 12:27:37 UTC
Size:
2.24 KB
patch
obsolete
>From ef437356e38e576a3db11fa03d3a0a39a4689a7a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 10 Mar 2023 16:14:50 +0000 >Subject: [PATCH] Bug 33493: Add a filter relationship for branchtransfers > >Prefetching is useful, but we don't want to fetch all the inactive >transfers for an item. This patch adds a filtered relationship and >updates get_transfer(s) to use this > >To test: >prove -v t/db_dependent/Koha/Item.t > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Item.pm | 11 +++++------ > Koha/Schema/Result/Item.pm | 10 ++++++++++ > 2 files changed, 15 insertions(+), 6 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index ea2677a01f..d38265903f 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -565,7 +565,9 @@ we still expect the item to end up at a final location eventually. > sub get_transfer { > my ($self) = @_; > >- return $self->get_transfers->search( {}, { rows => 1 } )->next; >+ my $transfer = $self->_result->branchtransfer; >+ >+ return Koha::Item::Transfers->_new_from_dbic($transfer)->next; > } > > =head3 get_transfers >@@ -588,12 +590,9 @@ we still expect the item to end up at a final location eventually. > sub get_transfers { > my ($self) = @_; > >- my $transfer_rs = $self->_result->branchtransfers; >+ my $transfer_rs = $self->_result->branchtransfer; > >- return Koha::Item::Transfers >- ->_new_from_dbic($transfer_rs) >- ->filter_by_current >- ->search( {}, { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ], } ); >+ return Koha::Item::Transfers->_new_from_dbic($transfer_rs); > } > > =head3 last_returned_by >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 308a63f804..72112d27d3 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -972,6 +972,16 @@ __PACKAGE__->many_to_many( > "ordernumber", > ); > >+__PACKAGE__->has_many( >+ "branchtransfer", >+ "Koha::Schema::Result::Branchtransfer", >+ { 'foreign.itemnumber' => 'self.itemnumber' }, >+ { >+ where => { datearrived => undef, datecancelled => undef }, >+ order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ] >+ } >+); >+ > use C4::Context; > sub effective_itemtype { > my ( $self ) = @_; >-- >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 33493
:
149464
|
149469
|
151865
|
151923
|
151924
|
151976
|
151977
|
151978