Bug 24467: Remove _count methods introduced for API use
This patch removes some methods that were introduced for API usage in the first iteration of the object embedding development effort. Those methods were obsoleted by bug 24528, which introduces a smarter way for Koha::Object->to_api to embed *_count attributes on the output structure based on the relationships and a call to ->count. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass 3. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
2dde059059
commit
77979a03b4
|
|
@ -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();
|
||||
|
|
@ -517,22 +503,6 @@ sub subscriptions {
|
|||
return $self->{_subscriptions};
|
||||
}
|
||||
|
||||
=head3 subscriptions_count
|
||||
|
||||
my $subscriptions_count = $self->subscriptions_count
|
||||
|
||||
Returns the count of the the related Koha::Subscriptions object for this biblio
|
||||
|
||||
IMPORTANT: this method is temporary and should not be used.
|
||||
|
||||
=cut
|
||||
|
||||
sub subscriptions_count {
|
||||
my ($self) = @_;
|
||||
|
||||
return $self->subscriptions->count;
|
||||
}
|
||||
|
||||
=head3 has_items_waiting_or_intransit
|
||||
|
||||
my $itemsWaitingOrInTransit = $biblio->has_items_waiting_or_intransit
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -92,15 +92,15 @@ subtest 'hidden_in_opac() tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'items() and items_count() tests' => sub {
|
||||
subtest 'items() tests' => sub {
|
||||
|
||||
plan tests => 5;
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $biblio = $builder->build_sample_biblio();
|
||||
|
||||
is( $biblio->items_count, 0, 'No items, count is 0' );
|
||||
is( $biblio->items->count, 0, 'No items, count is 0' );
|
||||
|
||||
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
|
||||
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
|
||||
|
|
@ -108,7 +108,6 @@ subtest 'items() and items_count() tests' => sub {
|
|||
my $items = $biblio->items;
|
||||
is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' );
|
||||
is( $items->count, 2, 'Two items in resultset' );
|
||||
is( $biblio->items_count, $items->count, 'items_count returns the expected value' );
|
||||
|
||||
my @items = $biblio->items->as_list;
|
||||
is( scalar @items, 2, 'Same result, but in list context' );
|
||||
|
|
@ -496,19 +495,19 @@ subtest 'suggestions() tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'orders() and active_orders_count() tests' => sub {
|
||||
subtest 'orders() and active_orders() tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 5;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $biblio = $builder->build_sample_biblio();
|
||||
|
||||
my $orders = $biblio->orders;
|
||||
my $active_orders_count = $biblio->active_orders_count;
|
||||
my $orders = $biblio->orders;
|
||||
my $active_orders = $biblio->active_orders;
|
||||
|
||||
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
|
||||
is( $orders->count, $active_orders_count, '->orders_count returns the count for the resultset' );
|
||||
is( $biblio->orders->count, $biblio->active_orders->count, '->orders_count returns the count for the resultset' );
|
||||
|
||||
# Add a couple orders
|
||||
foreach (1..2) {
|
||||
|
|
@ -534,17 +533,18 @@ subtest 'orders() and active_orders_count() tests' => sub {
|
|||
);
|
||||
|
||||
$orders = $biblio->orders;
|
||||
$active_orders_count = $biblio->active_orders_count;
|
||||
$active_orders = $biblio->active_orders;
|
||||
|
||||
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
|
||||
is( $orders->count, $active_orders_count + 2, '->active_orders_count returns the rigt count' );
|
||||
is( ref($active_orders), 'Koha::Acquisition::Orders', 'Result type is correct' );
|
||||
is( $orders->count, $active_orders->count + 2, '->active_orders_count returns the rigt count' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'subscriptions() and subscriptions_count() tests' => sub {
|
||||
subtest 'subscriptions() tests' => sub {
|
||||
|
||||
plan tests => 6;
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -555,7 +555,6 @@ subtest 'subscriptions() and subscriptions_count() tests' => sub {
|
|||
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
|
||||
);
|
||||
is( $subscriptions->count, 0, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
|
||||
is( $biblio->subscriptions_count, 0, 'subscriptions_count returns the correct number' );
|
||||
|
||||
# Add two subscriptions
|
||||
foreach (1..2) {
|
||||
|
|
@ -572,7 +571,6 @@ subtest 'subscriptions() and subscriptions_count() tests' => sub {
|
|||
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
|
||||
);
|
||||
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
|
||||
is( $biblio->subscriptions_count, 2, 'subscriptions_count returns the correct number' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue