From d42e656a9f0745e1bb77298fd6598faaa6d4bb69 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 4 Aug 2011 14:53:36 -0400 Subject: [PATCH] Faster T-pac circ history retrieval * Take advantage of the new default sorting behavior of action.usr_visible_circs to perform limit/offset within the DB instead of fetching the whole circ history in the mod_perl code and sorting through it. * Also use the more powerful/verbose column transform syntax for calling stored procedures to retrieve only the historical circ IDs instead of the full circ objects, since we are re-fetching fleshed circ objects later in the code. Signed-off-by: Bill Erickson --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 58f635bc73..26b1d524a1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -727,26 +727,21 @@ sub load_myopac_circ_history { $ctx->{circ_history_limit} = $limit; $ctx->{circ_history_offset} = $offset; - my $circs = $e->json_query({ - from => ['action.usr_visible_circs', $e->requestor->id], - #limit => $limit || 25, - #offset => $offset || 0, + my $circ_ids = $e->json_query({ + select => { + au => [{ + column => 'id', + transform => 'action.usr_visible_circs', + result_field => 'id' + }] + }, + from => 'au', + where => {id => $e->requestor->id}, + limit => $limit, + offset => $offset }); - # XXX: order-by in the json_query above appears to do nothing, so in-query - # paging is not reallly an option. do the sorting/paging here - - # sort newest to oldest - $circs = [ sort { $b->{xact_start} cmp $a->{xact_start} } @$circs ]; - my @ids = map { $_->{id} } @$circs; - - # find the selected page and trim cruft - @ids = @ids[$offset..($offset + $limit - 1)] if $limit; - @ids = grep { defined $_ } @ids; - - $ctx->{circs} = $self->fetch_user_circs(1, \@ids); - #$ctx->{circs} = $self->fetch_user_circs(1, [map { $_->{id} } @$circs], $limit, $offset); - + $ctx->{circs} = $self->fetch_user_circs(1, [map { $_->{id} } @$circ_ids]); return Apache2::Const::OK; } -- 2.43.2