Bugzilla – Attachment 97746 Details for
Bug 24467
*_count methods should be avoided
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24467: Remove _count methods
Bug-24467-Remove-count-methods.patch (text/plain), 4.55 KB, created by
Jonathan Druart
on 2020-01-22 16:21:07 UTC
(
hide
)
Description:
Bug 24467: Remove _count methods
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-22 16:21:07 UTC
Size:
4.55 KB
patch
obsolete
>From e08beacd1c3e26911cfd20765cfb4ca6169cdd88 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 22 Jan 2020 16:21:22 +0100 >Subject: [PATCH] Bug 24467: Remove _count methods > >Add a trick to guess what we need to call. > >Note that it does not work, do not know why. Tests are missing to make >sure everything is ok. >--- > Koha/Acquisition/Order.pm | 14 -------------- > Koha/Biblio.pm | 22 ++++------------------ > Koha/Object.pm | 9 ++++++++- > acqui/basket.pl | 4 ++-- > acqui/parcel.pl | 2 +- > 5 files changed, 15 insertions(+), 36 deletions(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 3ee51b926d..a944f3a6f4 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -194,20 +194,6 @@ sub holds { > ); > } > >-=head3 holds_count >- >- my $count = $order->holds_count >- >-Returns the holds count associated to the order. >- >-=cut >- >-sub holds_count { >- my ($self) = @_; >- >- return $self->holds->count; >-} >- > =head3 items > > my $items = $order->items >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 7c6e47328c..d8d1f09a3c 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -100,18 +100,18 @@ sub orders { > > =head3 active_orders_count > >-my $orders_count = $biblio->active_orders_count(); >+my $active_orders = $biblio->active_orders(); > >-Returns the number of active acquisition orders related to this biblio. >+Returns the active acquisition orders related to this biblio. > An order is considered active when it is not cancelled (i.e. when datecancellation > is not undef). > > =cut > >-sub active_orders_count { >+sub active_orders { > my ( $self ) = @_; > >- return $self->orders->search({ datecancellationprinted => undef })->count; >+ return $self->orders->search({ datecancellationprinted => undef }); > } > > =head3 can_article_request >@@ -411,20 +411,6 @@ sub items { > return Koha::Items->_new_from_dbic( $items_rs ); > } > >-=head3 items_count >- >-my $items_count = $biblio->items(); >- >-Returns the count of the the related Koha::Items object for this biblio >- >-=cut >- >-sub items_count { >- my ($self) = @_; >- >- return $self->_result->items->count; >-} >- > =head3 itemtype > > my $itemtype = $biblio->itemtype(); >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 5f28c35808..1f954fe451 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -431,7 +431,14 @@ sub to_api { > my $curr = $embed; > my $next = $embeds->{$curr}->{children}; > >- my $children = $self->$curr; >+ my $children; >+ my $method = $curr; >+ if ( $method =~ q{^(.*)_count$} ) { >+ $children = $self->$1; >+ $children = $children->count; >+ } else { >+ $children = $self->$curr; >+ } > > if ( defined $children and ref($children) eq 'ARRAY' ) { > my @list = map { >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 65ed547452..d248f11c92 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -136,7 +136,7 @@ if ( $op eq 'delete_confirm' ) { > foreach my $myorder (@orders){ > my $biblionumber = $myorder->{'biblionumber'}; > my $biblio = Koha::Biblios->find( $biblionumber ); >- my $countbiblio = $biblio->active_orders_count; >+ my $countbiblio = $biblio->active_orders->count; > my $ordernumber = $myorder->{'ordernumber'}; > my $cnt_subscriptions = $biblio->subscriptions->count; > my $itemcount = $biblio->items->count; >@@ -477,7 +477,7 @@ sub get_order_infos { > my $biblionumber = $order->{'biblionumber'}; > if ( $biblionumber ) { # The biblio still exists > my $biblio = Koha::Biblios->find( $biblionumber ); >- my $countbiblio = $biblio->active_orders_count; >+ my $countbiblio = $biblio->active_orders->count; > > my $ordernumber = $order->{'ordernumber'}; > my $cnt_subscriptions = $biblio->subscriptions->count; >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index 8139cabfb9..3fcc211b20 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -241,7 +241,7 @@ unless( defined $invoice->{closedate} ) { > > my $biblionumber = $line{'biblionumber'}; > my $biblio = Koha::Biblios->find( $biblionumber ); >- my $countbiblio = $biblio->active_orders_count; >+ my $countbiblio = $biblio->active_orders->count; > my $ordernumber = $line{'ordernumber'}; > my $order_object = Koha::Acquisition::Orders->find($ordernumber); > my $cnt_subscriptions = $biblio ? $biblio->subscriptions->count: 0; >-- >2.11.0
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 24467
:
97746
|
98198
|
98202
|
98218
|
98219
|
98220