[Koha-bugs] [Bug 22407] OMNIBUS: Use DBIC relations to fetch related object rather than searching for the object

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Feb 26 19:09:23 CET 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22407

--- Comment #3 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
We have already everything in our code:

Koha::Item->biblio
 93 sub biblio {
 94     my ( $self ) = @_;
 95     my $biblio_rs = $self->_result->biblio;
 96     return Koha::Biblio->_new_from_dbic( $biblio_rs );
 97 }

Koha::Item->checkout
121 sub checkout {
122     my ( $self ) = @_;
123     my $checkout_rs = $self->_result->issue;
124     return unless $checkout_rs;
125     return Koha::Checkout->_new_from_dbic( $checkout_rs );
126 }

Koha::Item->current_holds
271 sub current_holds {
272     my ( $self ) = @_;
273     my $attributes = { order_by => 'priority' };
274     my $dtf = Koha::Database->new->schema->storage->datetime_parser;
275     my $params = {
276         itemnumber => $self->itemnumber,
277         suspend => 0,
278         -or => [
279             reservedate => { '<=' => $dtf->format_date(dt_from_string) },
280             waitingdate => { '!=' => undef },
281         ],
282     };
283     my $hold_rs = $self->_result->reserves->search( $params, $attributes );
284     return Koha::Holds->_new_from_dbic($hold_rs);
285 }

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list