Bugzilla – Attachment 125241 Details for
Bug 29083
Update article requests-related Koha::Patron methods to use relationships
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29083: Update article requests-related Koha::Patron methods to use relationships
Bug-29083-Update-article-requests-related-KohaPatr.patch (text/plain), 3.61 KB, created by
Martin Renvoize (ashimema)
on 2021-09-24 13:01:20 UTC
(
hide
)
Description:
Bug 29083: Update article requests-related Koha::Patron methods to use relationships
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-09-24 13:01:20 UTC
Size:
3.61 KB
patch
obsolete
>From 97daf7186d2a8240c84d2129db8a1e4a9ee271db Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Sep 2021 15:49:15 -0300 >Subject: [PATCH] Bug 29083: Update article requests-related Koha::Patron > methods to use relationships > >This patch makes Koha::Patron->article_requests use the underlying DBIC >relationship and _new_from_dbic instead of a plain search. It also >refactors 'article_requests_current' and 'article_requests_finished' to >use ->article_requests, as well as the new methods introduced by bug >29082 for filtering. > >No behavior change should take place. > >To test: >1. Apply the unit tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron.t \ > t/db_dependent/ArticleRequests.t >=> SUCCESS: Tests pass! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron.pm | 42 ++++++++---------------------------------- > 1 file changed, 8 insertions(+), 34 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 967ae9a33b2..37d07375ad9 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -983,26 +983,21 @@ sub can_request_article { > > =head3 article_requests > >-my @requests = $borrower->article_requests(); >-my $requests = $borrower->article_requests(); >+ my $article_requests = $patron->article_requests; > >-Returns either a list of ArticleRequests objects, >-or an ArtitleRequests object, depending on the >-calling context. >+Returns the patron article requests. > > =cut > > sub article_requests { >- my ( $self ) = @_; >- >- $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() }); >+ my ($self) = @_; > >- return $self->{_article_requests}; >+ return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); > } > > =head3 article_requests_current > >-my @requests = $patron->article_requests_current >+ my $current_article_requests = $patron->article_requests_current > > Returns the article requests associated with this patron that are incomplete > >@@ -1011,23 +1006,12 @@ Returns the article requests associated with this patron that are incomplete > sub article_requests_current { > my ( $self ) = @_; > >- $self->{_article_requests_current} ||= Koha::ArticleRequests->search( >- { >- borrowernumber => $self->id(), >- -or => [ >- { status => Koha::ArticleRequest::Status::Requested }, >- { status => Koha::ArticleRequest::Status::Pending }, >- { status => Koha::ArticleRequest::Status::Processing } >- ] >- } >- ); >- >- return $self->{_article_requests_current}; >+ return $self->article_requests->filter_by_current; > } > > =head3 article_requests_finished > >-my @requests = $biblio->article_requests_finished >+ my $finished_article_requests = $biblio->article_requests_finished > > Returns the article requests associated with this patron that are completed > >@@ -1036,17 +1020,7 @@ Returns the article requests associated with this patron that are completed > sub article_requests_finished { > my ( $self, $borrower ) = @_; > >- $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( >- { >- borrowernumber => $self->id(), >- -or => [ >- { status => Koha::ArticleRequest::Status::Completed }, >- { status => Koha::ArticleRequest::Status::Canceled } >- ] >- } >- ); >- >- return $self->{_article_requests_finished}; >+ return $self->article_requests->filter_by_finished; > } > > =head3 add_enrolment_fee_if_needed >-- >2.20.1
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 29083
:
125160
|
125161
|
125162
|
125186
|
125240
|
125241
|
125242
|
125243
|
125268
|
125269
|
125270
|
125271
|
125640
|
125641
|
125642
|
125643
|
125833
|
125834
|
125835
|
125836
|
125837
|
125838
|
125840
|
125862