Bugzilla – Attachment 73570 Details for
Bug 19935
Move C4::Members::GetPendingIssues to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19935: Add Koha::Patron->pending_checkouts
Bug-19935-Add-KohaPatron-pendingcheckouts.patch (text/plain), 4.73 KB, created by
Josef Moravec
on 2018-04-03 13:13:18 UTC
(
hide
)
Description:
Bug 19935: Add Koha::Patron->pending_checkouts
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-04-03 13:13:18 UTC
Size:
4.73 KB
patch
obsolete
>From a945169e7db95998768e1eab44907d3db9acb5a5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Jan 2018 15:49:03 -0300 >Subject: [PATCH] Bug 19935: Add Koha::Patron->pending_checkouts > >To move this subroutine out of the C4 namespace we face the same >problematic as bug 17553 (with GetOverduesForPatron). >We need to provide an equivalent method and so return all the related >value for a given checkout. >We can acchieve the easily using Koha::Object->unblessed_all_relateds, >but we need to keep in mind that it is a temporary move. >Indeed we will want to use our API to only access/retrive values we really need. >The whole trick could be removed when the current syntax for notices >will be deprecated and removed. > >Note: this method returns the same number of elements than ->checkouts >They indeed returns the same things, but it sounds better to me to have a >different method to highlight (from the callers) where does it come >from (C4::Members::GetPendingIssues). > >Signed-off-by: Benjamin Rokseth <benjamin.rokseth@deichman.no> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Patron.pm | 31 +++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Patrons.t | 13 +++++++++++-- > 2 files changed, 42 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 0938bbb..2322131 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -523,6 +523,37 @@ sub checkouts { > return Koha::Checkouts->_new_from_dbic( $checkouts ); > } > >+=head3 pending_checkouts >+ >+my $pending_checkouts = $patron->pending_checkouts >+ >+This method will return the same as $self->checkouts, but with a prefetch on >+items, biblio and biblioitems. >+ >+It has been introduced to replaced the C4::Members::GetPendingIssues subroutine >+ >+It should not be used directly, prefer to access fields you need instead of >+retrieving all these fields in one go. >+ >+ >+=cut >+ >+sub pending_checkouts { >+ my( $self ) = @_; >+ my $checkouts = $self->_result->issues->search( >+ {}, >+ { >+ order_by => [ >+ { -desc => 'me.timestamp' }, >+ { -desc => 'issuedate' }, >+ { -desc => 'issue_id' }, # Sort by issue_id should be enough >+ ], >+ prefetch => { item => { biblio => 'biblioitems' } }, >+ } >+ ); >+ return Koha::Checkouts->_new_from_dbic( $checkouts ); >+} >+ > =head3 old_checkouts > > my $old_checkouts = $patron->old_checkouts >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index c494241..87ae26d 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -428,8 +428,8 @@ subtest 'add_enrolment_fee_if_needed' => sub { > $patron->delete; > }; > >-subtest 'checkouts + get_overdues + old_checkouts' => sub { >- plan tests => 12; >+subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { >+ plan tests => 17; > > my $library = $builder->build( { source => 'Branch' } ); > my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >@@ -481,6 +481,9 @@ subtest 'checkouts + get_overdues + old_checkouts' => sub { > my $checkouts = $patron->checkouts; > is( $checkouts->count, 0, 'checkouts should not return any issues for that patron' ); > is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' ); >+ my $pending_checkouts = $patron->pending_checkouts; >+ is( $pending_checkouts->count, 0, 'pending_checkouts should not return any issues for that patron' ); >+ is( ref($pending_checkouts), 'Koha::Checkouts', 'pending_checkouts should return a Koha::Checkouts object' ); > my $old_checkouts = $patron->old_checkouts; > is( $old_checkouts->count, 0, 'old_checkouts should not return any issues for that patron' ); > is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' ); >@@ -499,6 +502,12 @@ subtest 'checkouts + get_overdues + old_checkouts' => sub { > $checkouts = $patron->checkouts; > is( $checkouts->count, 3, 'checkouts should return 3 issues for that patron' ); > is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' ); >+ $pending_checkouts = $patron->pending_checkouts; >+ is( $pending_checkouts->count, 3, 'pending_checkouts should return 3 issues for that patron' ); >+ is( ref($pending_checkouts), 'Koha::Checkouts', 'pending_checkouts should return a Koha::Checkouts object' ); >+ >+ my $first_checkout = $pending_checkouts->next; >+ is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->{biblionumber}, 'pending_checkouts should prefetch values from other tables (here biblio)' ); > > my $overdues = $patron->get_overdues; > is( $overdues->count, 2, 'Patron should have 2 overdues'); >-- >2.1.4
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 19935
:
70351
|
70352
|
70353
|
70354
|
70355
|
70356
|
70357
|
70358
|
70359
|
70360
|
70361
|
71807
|
71808
|
71809
|
71810
|
71811
|
71812
|
71813
|
72752
|
72753
|
72754
|
72755
|
72756
|
72757
|
72758
|
72759
|
72760
|
72761
|
72762
|
73557
|
73558
|
73559
|
73560
|
73561
|
73562
|
73563
|
73564
|
73565
|
73566
|
73567
|
73568
|
73569
| 73570 |
73571
|
73572
|
73573
|
73574
|
73575
|
73576
|
73577
|
73578
|
73579
|
73580
|
73581
|
73582