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 <mrylander@gmail.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
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 => [{
from => 'aou',
where => {id => $pld}
}
- };
+ } if ($pld != $top_ou->id);
}