This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects.
Created attachment 36947 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized.
Kyle, please fix the POD, it's incorrect in some places.
Comment on attachment 36947 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects Review of attachment 36947 [details] [review]: ----------------------------------------------------------------- Please provide tests for new packages. ::: circ/circulation.pl @@ +389,4 @@ > # BUILD HTML > # show all reserves of this borrower, and the position of the reservation .... > if ($borrowernumber) { > + my $holds = Koha::Holds->new()->search( { borrowernumber => $borrowernumber } ); Koha::Holds->search should be enough.
Created attachment 37303 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized.
Kyle, I ran through the steps on a sandbox. 1. "Waiting at" is still bold, but not different colored. 2. Selecting Hold in the circulation.pl continues to show the "Processing" box.
Created attachment 38175 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized.
(In reply to Jason Burds from comment #5) > Kyle, > > I ran through the steps on a sandbox. > > 1. "Waiting at" is still bold, but not different colored. That is exactly how it should be! I apologize for not being more specific in my test plan. The only difference is the color change, the text is bold for holds both at your branch and other branches. > 2. Selecting Hold in the circulation.pl continues to show the "Processing" > box. That appears to be fixed in master and was unrelated to this patch.
Created attachment 39740 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized.
Created attachment 40028 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized.
Created attachment 40039 [details] [review] [SIGNED-OFF] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Cathi Wiggins <CWIGGINS@ci.arcadia.ca.us> Signed-off-by: Megan Wianecki <mwianecki@mplmain.mtpl.org>
Comment on attachment 40039 [details] [review] [SIGNED-OFF] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects Review of attachment 40039 [details] [review]: ----------------------------------------------------------------- There is a lack of tests for new module added by this patch. ::: Koha/Branches.pm @@ +28,5 @@ > +use base qw(Koha::Objects); > + > +=head1 NAME > + > +Koha::Branches - Koha Reserve object set class s/Reserve/Branch ::: Koha/Hold.pm @@ +45,5 @@ > + > +sub biblio { > + my ($self) = @_; > + > + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); Why not return $self->{_result}->biblio; ? @@ +59,5 @@ > + > +sub item { > + my ($self) = @_; > + > + $self->{_item} ||= Koha::Items->find( $self->itemnumber() ); Same as before. @@ +73,5 @@ > + > +sub branch { > + my ($self) = @_; > + > + $self->{_branch} ||= Koha::Branches->find( $self->branchcode() ); Same as before. ::: koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ +763,5 @@ > > + [% IF ( WaitingHolds ) %] > + <div id="holdswaiting" class="circmessage"> > + <h4>Holds waiting:</h4> > + [% FOREACH w IN WaitingHolds %] WaitingHolds is an array?? You have passed WaitingHolds => scalar $holds->waiting() in the pl script.
> There is a lack of tests for new module added by this patch. I'll add some unit tests! > ::: Koha/Hold.pm > @@ +45,5 @@ > > + > > +sub biblio { > > + my ($self) = @_; > > + > > + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); > > Why not > return $self->{_result}->biblio; > ? That would return a DBIC restultset and not a Koha::Biblios object. > ::: koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt > @@ +763,5 @@ > > > > + [% IF ( WaitingHolds ) %] > > + <div id="holdswaiting" class="circmessage"> > > + <h4>Holds waiting:</h4> > > + [% FOREACH w IN WaitingHolds %] > > WaitingHolds is an array?? > You have passed > WaitingHolds => scalar $holds->waiting() > in the pl script. WaitingHolds is a Koha::Holds object, which Template Toolkit can iterate over.
Created attachment 40247 [details] [review] Bug 13851 [QA Followup] - Unit Tests
(In reply to Kyle M Hall from comment #12) > > There is a lack of tests for new module added by this patch. > > I'll add some unit tests! Thanks! > > ::: Koha/Hold.pm > > @@ +45,5 @@ > > > + > > > +sub biblio { > > > + my ($self) = @_; > > > + > > > + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); > > > > Why not > > return $self->{_result}->biblio; > > ? > > That would return a DBIC restultset and not a Koha::Biblios object. Yes, you are right, sorry. We will have to create a method for each FK. I don't have a better idea to suggest at the moment. > > ::: koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt > > @@ +763,5 @@ > > > > > > + [% IF ( WaitingHolds ) %] > > > + <div id="holdswaiting" class="circmessage"> > > > + <h4>Holds waiting:</h4> > > > + [% FOREACH w IN WaitingHolds %] > > > > WaitingHolds is an array?? > > You have passed > > WaitingHolds => scalar $holds->waiting() > > in the pl script. > > WaitingHolds is a Koha::Holds object, which Template Toolkit can iterate > over. Ok, I thought you passed the number of holds, but actually it's a Koha::Holds ref.
Created attachment 40256 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Cathi Wiggins <CWIGGINS@ci.arcadia.ca.us> Signed-off-by: Megan Wianecki <mwianecki@mplmain.mtpl.org> Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Created attachment 40257 [details] [review] Bug 13851 [QA Followup] - Unit Tests Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Created attachment 40258 [details] [review] Bug 13851: Fix typo in POD Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Created attachment 40668 [details] [review] Bug 13851 - Replace waiting holds logic in circulation.pl with Koha Objects This is the original patch for bug 12892 and replaces the older style of fetching the holds data with Koha Objects. It will be used as a foundation for future features. Test Plan: 1) Apply this patch 2) Create a hold, set to waiting 3) Browse to circulation.pl for that patron 4) Note you see the list of waiting holds 5) Switch your logged in branch to a different branch 6) Note the "Waiting at" line is no longer emphasized. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Cathi Wiggins <CWIGGINS@ci.arcadia.ca.us> Signed-off-by: Megan Wianecki <mwianecki@mplmain.mtpl.org> Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Created attachment 40669 [details] [review] Bug 13851 [QA Followup] - Unit Tests Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Created attachment 40670 [details] [review] Bug 13851: Fix typo in POD Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Patches pushed to master. Thanks Kyle!
Hi there! Tomás asked me to comment on this. I have nothing major to complain, all looks good to me. I spotted one optimization however: +++ b/Koha/Hold.pm +sub biblio { + my ($self) = @_; + + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); + + return $self->{_biblio}; +} When you get the linked object like this 'Koha::Biblios->find()', you need to instantiate a new DBIx::Class::ResultSet to make the search. There is already an instantiated resultset in Koha::Hold (the caller class). Should we instead get the linked data like this? #The relationship is already defined in the DBIx::Schema my $b = $self->_resultset()->biblio() $b = $self->_new_from_dbic($b); using the DBIx::Schema's preconfigured relationships?
(In reply to Olli-Antti Kivilahti from comment #22) > Hi there! > Tomás asked me to comment on this. > > I have nothing major to complain, all looks good to me. > I spotted one optimization however: Olli, would you be kind and fill a bug report with your enhancement proposal?