From 02312ad8f30dd4e9c15e866877ff09e7a5c08086 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 26 Jul 2006 17:26:46 +0000 Subject: [PATCH] added caching to prox calc; calculating proximity to circ_lib instead of owning_lib git-svn-id: svn://svn.open-ils.org/ILS/trunk@5112 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/asset.pm | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm index 3a813ec528..2031cc1672 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm @@ -389,6 +389,7 @@ __PACKAGE__->register_method( ); +my %_prox_cache; sub copy_proximity { my $self = shift; my $client = shift; @@ -398,12 +399,28 @@ sub copy_proximity { return unless ($cp && $org); - $cp = $cp->id if (ref $cp); + my $key; + if (ref($cp)) { + + my $ol = $cp->circ_lib; + + $key = "$ol|$org"; + $key = "$org|$ol" if ($ol->id > $org); + return $_prox_cache{$key} if (exists($_prox_cache{$key})); + } + $cp = asset::copy->retrieve($cp); + return unless $copy; - my $ol = $cp->call_number->owning_lib; + my $ol = $cp->circ_lib; + + $key = "$ol|$org"; + $key = "$org|$ol" if ($ol->id > $org); + + $_prox_cache{$key} = asset::copy->db_Main->selectcol_arrayref('SELECT actor.org_unit_proximity(?,?)',{},"$ol","$org")->[0]; + unless (exists($_prox_cache{$key})); - return asset::copy->db_Main->selectcol_arrayref('SELECT actor.org_unit_proximity(?,?)',{},"$ol","$org")->[0]; + return $_prox_cache{$key}; } __PACKAGE__->register_method( method => 'copy_proximity', -- 2.43.2