From e6d8b8c5d5a2d7c56239d80bf04e3362823ce068 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 3 Aug 2011 16:04:26 -0400 Subject: [PATCH] Speed up hold editing by only fetching hold to edit Signed-off-by: Bill Erickson --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 7 ++++--- .../templates/default/opac/myopac/holds/edit.tt2 | 22 ++++++++-------------- 2 files changed, 12 insertions(+), 17 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 fbdd904502..58f635bc73 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -309,10 +309,11 @@ sub fetch_user_holds { sub handle_hold_update { my $self = shift; my $action = shift; + my $hold_ids = shift; my $e = $self->editor; my $url; - my @hold_ids = $self->cgi->param('hold_id'); # for non-_all actions + my @hold_ids = ($hold_ids) ? @$hold_ids : $self->cgi->param('hold_id'); # for non-_all actions @hold_ids = @{$self->fetch_user_holds(undef, 1)} if $action =~ /_all/; my $circ = OpenSRF::AppSession->create('open-ils.circ'); @@ -375,16 +376,16 @@ sub load_myopac_holds { my $e = $self->editor; my $ctx = $self->ctx; - my $limit = $self->cgi->param('limit') || 0; my $offset = $self->cgi->param('offset') || 0; my $action = $self->cgi->param('action') || ''; + my $hold_id = $self->cgi->param('id'); my $available = int($self->cgi->param('available') || 0); my $hold_handle_result; $hold_handle_result = $self->handle_hold_update($action) if $action; - $ctx->{holds} = $self->fetch_user_holds(undef, 0, 1, $available, $limit, $offset); + $ctx->{holds} = $self->fetch_user_holds($hold_id ? [$hold_id] : undef, 0, 1, $available, $limit, $offset); return defined($hold_handle_result) ? $hold_handle_result : Apache2::Const::OK; } diff --git a/Open-ILS/web/templates/default/opac/myopac/holds/edit.tt2 b/Open-ILS/web/templates/default/opac/myopac/holds/edit.tt2 index 53e12c9b7b..2fda76c044 100644 --- a/Open-ILS/web/templates/default/opac/myopac/holds/edit.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/holds/edit.tt2 @@ -5,21 +5,15 @@ "default/opac/parts/myopac/base.tt2"; myopac_page = "holds"; # in this case, just for tab coloring. - hold = 0; - FOR h IN ctx.holds; - IF h.hold.hold.id == CGI.param('id'); - hold = h; - ahr = hold.hold.hold; - attrs = {marc_xml => hold.marc_xml}; - PROCESS get_marc_attrs args=attrs; - hold.human_status = PROCESS get_hold_status hold=hold; + hold = ctx.holds.0; + ahr = hold.hold.hold; + attrs = {marc_xml => hold.marc_xml}; + PROCESS get_marc_attrs args=attrs; + hold.human_status = PROCESS get_hold_status hold=hold; - # Do this up front to avoid verbosity later - expire_time = ahr.expire_time ? date.format(ctx.parse_datetime(ahr.expire_time), DATE_FORMAT) : ''; - thaw_date = ahr.thaw_date ? date.format(ctx.parse_datetime(ahr.thaw_date), DATE_FORMAT) : ''; - LAST; - END; - END; + # Do this up front to avoid verbosity later + expire_time = ahr.expire_time ? date.format(ctx.parse_datetime(ahr.expire_time), DATE_FORMAT) : ''; + thaw_date = ahr.thaw_date ? date.format(ctx.parse_datetime(ahr.thaw_date), DATE_FORMAT) : ''; %]
-- 2.11.0