Bugzilla – Attachment 125164 Details for
Bug 29084
Update article requests-related Koha::Biblio methods to use relationships
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29084: Update article requests-related Koha::Biblio methods to use relationships
Bug-29084-Update-article-requests-related-KohaBibl.patch (text/plain), 3.64 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-09-22 19:26:20 UTC
(
hide
)
Description:
Bug 29084: Update article requests-related Koha::Biblio methods to use relationships
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-09-22 19:26:20 UTC
Size:
3.64 KB
patch
obsolete
>From 77158ca2d2032cbc70e05c5ae42b8e283eb18e65 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Sep 2021 16:19:21 -0300 >Subject: [PATCH] Bug 29084: Update article requests-related Koha::Biblio > 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/Biblio.t \ > t/db_dependent/ArticleRequests.t >=> SUCCESS: Tests pass! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D >--- > Koha/Biblio.pm | 45 +++++++++++---------------------------------- > 1 file changed, 11 insertions(+), 34 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index d1d84a7631..968a370b25 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -341,67 +341,44 @@ sub article_request_type_for_items { > > =head3 article_requests > >-my @requests = $biblio->article_requests >+ my $article_requests = $biblio->article_requests > >-Returns the article requests associated with this Biblio >+Returns the article requests associated with this biblio > > =cut > > sub article_requests { >- my ( $self, $borrower ) = @_; >- >- $self->{_article_requests} ||= Koha::ArticleRequests->search( { biblionumber => $self->biblionumber() } ); >+ my ( $self ) = @_; > >- return wantarray ? $self->{_article_requests}->as_list : $self->{_article_requests}; >+ return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); > } > > =head3 article_requests_current > >-my @requests = $biblio->article_requests_current >+ my $current_article_requests = $biblio->article_requests_current > >-Returns the article requests associated with this Biblio that are incomplete >+Returns the article requests associated with this biblio that are incomplete > > =cut > > sub article_requests_current { >- my ( $self, $borrower ) = @_; >- >- $self->{_article_requests_current} ||= Koha::ArticleRequests->search( >- { >- biblionumber => $self->biblionumber(), >- -or => [ >- { status => Koha::ArticleRequest::Status::Requested }, >- { status => Koha::ArticleRequest::Status::Pending }, >- { status => Koha::ArticleRequest::Status::Processing } >- ] >- } >- ); >+ my ( $self ) = @_; > >- return wantarray ? $self->{_article_requests_current}->as_list : $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 Biblio that are completed >+Returns the article requests associated with this biblio that are completed > > =cut > > sub article_requests_finished { > my ( $self, $borrower ) = @_; > >- $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( >- { >- biblionumber => $self->biblionumber(), >- -or => [ >- { status => Koha::ArticleRequest::Status::Completed }, >- { status => Koha::ArticleRequest::Status::Canceled } >- ] >- } >- ); >- >- return wantarray ? $self->{_article_requests_finished}->as_list : $self->{_article_requests_finished}; >+ return $self->article_requests->filter_by_finished; > } > > =head3 items >-- >2.30.2
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 29084
:
125163
|
125164
|
125244
|
125245
|
125841
|
125842
|
125843