Bugzilla – Attachment 149469 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
David Nind
on 2023-04-11 19:09:30 UTC
(
hide
)
Description:
Bug 33493: Add a filter relationship for branchtransfers
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-04-11 19:09:30 UTC
Size:
2.24 KB
patch
obsolete
>From 1513f253c661a5c687c646f3ac8565956a0c12b8 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 0d29655938..f7c618a318 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -564,7 +564,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 >@@ -587,12 +589,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 55d33e4a19..fe729f1849 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -968,6 +968,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