Bugzilla – Attachment 148085 Details for
Bug 33167
Cleanup staff interface catalog details page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33167: Add a filter rleationship for branchtransfer
Bug-33167-Add-a-filter-rleationship-for-branchtran.patch (text/plain), 3.22 KB, created by
Nick Clemens (kidclamp)
on 2023-03-10 16:16:43 UTC
(
hide
)
Description:
Bug 33167: Add a filter rleationship for branchtransfer
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-03-10 16:16:43 UTC
Size:
3.22 KB
patch
obsolete
>From fcf777198ae47a93e22930cca410673a7db57040 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 33167: Add a filter rleationship for branchtransfer > >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 to use this >--- > Koha/Biblio.pm | 7 +++---- > Koha/Item.pm | 4 +++- > Koha/Schema/Result/Item.pm | 14 ++++++++++++++ > catalogue/detail.pl | 2 +- > 4 files changed, 21 insertions(+), 6 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 0e06a14fa0..481be204df 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -435,11 +435,10 @@ sub items { > > return Koha::Items->_new_from_dbic( $items_rs ) unless $params->{host_items}; > >+ my @itemnumbers = $items_rs->get_column('itemnumber')->all; > my $host_itemnumbers = $self->_host_itemnumbers(); >- my $params = { -or => [biblionumber => $self->id] }; >- push @{$params->{'-or'}}, itemnumber => { -in => $host_itemnumbers } if $host_itemnumbers; >- >- return Koha::Items->search($params); >+ push @itemnumbers, @{ $host_itemnumbers }; >+ return Koha::Items->search({ "me.itemnumber" => { -in => \@itemnumbers } }); > } > > =head3 host_items >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 89d1a948c4..e6c47c2474 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -566,7 +566,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 >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 55d33e4a19..893172a367 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -968,6 +968,20 @@ __PACKAGE__->many_to_many( > "ordernumber", > ); > >+__PACKAGE__->has_many( >+ "branchtransfer", >+ "Koha::Schema::Result::Branchtransfer", >+ sub { >+ my $args = shift; >+ return { >+ "$args->{foreign_alias}.itemnumber" => { -ident => "$args->{self_alias}.itemnumber" }, >+ "$args->{foreign_alias}.datearrived" => undef, >+ "$args->{foreign_alias}.datecancelled" => undef, >+ }; >+ }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > use C4::Context; > sub effective_itemtype { > my ( $self ) = @_; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index f20ebf850e..01e1bdf06d 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -193,7 +193,7 @@ my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search_with_loc > my $params; > my $patron = Koha::Patrons->find( $borrowernumber ); > $params->{ itemlost } = 0 if $patron->category->hidelostitems && !$showallitems; >-my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','branchtransfers'] } ); >+my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','branchtransfer'] } ); > > # flag indicating existence of at least one item linked via a host record > my $hostrecords = $biblio->host_items->count; >-- >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 33167
:
148029
|
148082
|
148083
|
148084
|
148085
|
148431
|
148432
|
148433
|
148434
|
149677
|
149704
|
150075
|
150076