[open-ils-commits] r19132 - trunk/Open-ILS/src/perlmods/OpenILS/Application (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 6 23:58:08 EST 2011


Author: dbs
Date: 2011-01-06 23:58:05 -0500 (Thu, 06 Jan 2011)
New Revision: 19132

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Log:
Prevent tag array from growing insanely in supercat browses

Modifying the passed-in tag array reference apparently resulted
in those changes persisting to the next call, growing the tag
array at a rapid clip. So we needed to clean that up.

Also, applying the DISTINCT transform to the afr.record column, while
a valiant effort, didn't actually work. distinct() is not DISTINCT
ON () for starters; also, because DISTINCT ON needs to have the
ORDER BY clause match its arguments, and we actually want to order
by afr.value, not afr.record.

We could do it in a subquery, then reorder by value in the outer
SELECT, but it's not clear that json_query supports DISTINCT ON
anyway. Some days I wish I could just write SQL.

We could retrieve only the afr.record column - it's not clear that
any callers actually need the naco-normalized value column - but
that seems like a pretty major change at this point.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2011-01-06 18:47:21 UTC (rev 19131)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2011-01-07 04:58:05 UTC (rev 19132)
@@ -1006,13 +1006,13 @@
 	my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
 
 	# .refs variant includes 4xx and 5xx variants for see / see also
-	if ($self->api_name =~ /\.refs\./) {
-		my @ref_tags;
-		foreach my $tagname (@$tag) {
+	my @ref_tags = ();
+	foreach my $tagname (@$tag) {
+		push(@ref_tags, $tagname);
+		if ($self->api_name =~ /\.refs\./) {
 			push(@ref_tags, '4' . substr($tagname, 1, 2));
 			push(@ref_tags, '5' . substr($tagname, 1, 2));
 		}
-		push(@$tag, @ref_tags);
 	}
 
 	my @list = ();
@@ -1020,12 +1020,10 @@
 	if ($page < 0) {
 		my $before = $_storage->request(
 			"open-ils.cstore.json_query.atomic",
-			{ select	=> { afr => [
-				{ transform => "distinct", column => "record" },
-				"value" ]},
+			{ select	=> { afr => [qw/record value/] },
 			  from		=> { 'are', 'afr' },
 			  where		=> {
-				'+afr' => { tag => $tag, subfield => $subfield, value => { '<' => lc($value) } },
+				'+afr' => { tag => \@ref_tags, subfield => $subfield, value => { '<' => lc($value) } },
 				'+are' => { 'deleted' => 'f' }
 			  },
 			  order_by	=> { afr => { value => 'desc' } },
@@ -1039,12 +1037,10 @@
 	if ($page >= 0) {
 		my $after = $_storage->request(
 			"open-ils.cstore.json_query.atomic",
-			{ select	=> { afr => [
-				{ transform => "distinct", column => "record" },
-				"value" ]},
+			{ select	=> { afr => [qw/record value/] },
 			  from		=> { 'are', 'afr' },
 			  where		=> {
-				'+afr' => { tag => $tag, subfield => $subfield, value => { '>=' => lc($value) } },
+				'+afr' => { tag => \@ref_tags, subfield => $subfield, value => { '>=' => lc($value) } },
 				'+are' => { 'deleted' => 'f' }
 			  },
 			  order_by	=> { afr => { value => 'asc' } },
@@ -1496,14 +1492,14 @@
 	my $offset = $limit * abs($page);
 	my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
 
+	my @ref_tags = ();
 	# .refs variant includes 4xx and 5xx variants for see / see also
-	if ($self->api_name =~ /\.refs\./) {
-		my @ref_tags;
-		foreach my $tagname (@$tag) {
+	foreach my $tagname (@$tag) {
+		push(@ref_tags, $tagname);
+		if ($self->api_name =~ /\.refs\./) {
 			push(@ref_tags, '4' . substr($tagname, 1, 2));
 			push(@ref_tags, '5' . substr($tagname, 1, 2));
 		}
-		push(@$tag, @ref_tags);
 	}
 
 	my @list = ();
@@ -1514,12 +1510,10 @@
 
 		my $before = $_storage->request(
 			"open-ils.cstore.json_query.atomic",
-			{ select	=> { afr => [
-				{ transform => "distinct", column => "record" },
-				"value" ]},
+			{ select	=> { afr => [qw/record value/] },
 			  from		=> { 'afr', 'are' },
 			  where		=> {
-				'+afr' => { tag => $tag, subfield => $subfield, value => { '<' => lc($value) } },
+				'+afr' => { tag => \@ref_tags, subfield => $subfield, value => { '<' => lc($value) } },
 				'+are' => { deleted => 'f' }
 			  },
 			  order_by	=> { afr => { value => 'desc' } },
@@ -1533,12 +1527,10 @@
 	if ($page >= 0) {
 		my $after = $_storage->request(
 			"open-ils.cstore.json_query.atomic",
-			{ select	=> { afr => [
-				{ transform => "distinct", column => "record" },
-				"value" ]},
+			{ select	=> { afr => [qw/record value/] },
 			  from		=> { 'afr', 'are' },
 			  where		=> {
-				'+afr' => { tag => $tag, subfield => $subfield, value => { '>=' => lc($value) } },
+				'+afr' => { tag => \@ref_tags, subfield => $subfield, value => { '>=' => lc($value) } },
 				'+are' => { deleted => 'f' }
 			  },
 			  order_by	=> { afr => { value => 'asc' } },



More information about the open-ils-commits mailing list