Bugzilla – Attachment 97463 Details for
Bug 24435
Add Koha::Biblio->items_count
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24435: Add Koha::Biblio->items_count
Bug-24435-Add-KohaBiblio-itemscount.patch (text/plain), 1.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-01-16 16:36:47 UTC
(
hide
)
Description:
Bug 24435: Add Koha::Biblio->items_count
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-01-16 16:36:47 UTC
Size:
1.63 KB
patch
obsolete
>From 5155f09ff14a43763e2ae04d33890484c6b3de0b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 16 Jan 2020 13:32:25 -0300 >Subject: [PATCH] Bug 24435: Add Koha::Biblio->items_count > >This patch introduces a handy shortcut to get the items count for a >biblio. So instead of calling: > > $count = $biblio->items->count; >you can call: > $count = $biblio->items_count; > >The use case for this, is when we want to embed information on objects >to be sent as API responses. In that case, calling ->items->count needs >to be done manually on the controller script, with interesting added >complexity. With this kind of method, we can just require it to be >embedded automagically by calling the following on the API: > > $biblio->to_api({ embed => { items_count => {} } }); > >If there are several nested layers of objects, doing manually can get >really tricky and error prone. > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Biblio.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Biblio.pm | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index d0c291a528..7c6e47328c 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -411,6 +411,20 @@ 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(); >-- >2.25.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 24435
:
97462
|
97463
|
97489
|
97490
|
97561
|
97562