From 0c6580309531ec03ccf1a07b1e439e20289c475f Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 16 Jul 2013 16:58:57 -0400 Subject: [PATCH] Optimize away always-true hold count clause When rendering results in the tpac we request hold counts for each record. Most of the time (that is, whenever org unit hiding is /not/ in use) we filter, essentially, on "where pickup_lib is in the org tree". This is both useless and slow, so this commit will recognize that and optimize the test away. [LFW: fixed typo] Signed-off-by: Mike Rylander Signed-off-by: Lebbeous Fogle-Weekley --- .../src/perlmods/lib/OpenILS/Application/Circ/Holds.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index affbb2e8b4..cb99b3d3ff 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -4133,6 +4133,11 @@ sub rec_hold_count { if (my $pld = $args->{pickup_lib_descendant}) { + + my $top_ou = new_editor()->search_actor_org_unit( + {parent_ou => undef} + )->[0]; # XXX Assumes single root node. Not alone in this... + $query->{where}->{'+ahr'}->{pickup_lib} = { in => { select => {aou => [{ @@ -4143,7 +4148,7 @@ sub rec_hold_count { from => 'aou', where => {id => $pld} } - }; + } if ($pld != $top_ou->id); } -- 2.43.2