[open-ils-commits] r20430 - in branches/rel_2_1/Open-ILS/src: perlmods/lib/OpenILS/Application/Storage/Publisher sql/Pg sql/Pg/upgrade (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu May 5 12:44:27 EDT 2011


Author: senator
Date: 2011-05-05 12:44:23 -0400 (Thu, 05 May 2011)
New Revision: 20430

Added:
   branches/rel_2_1/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql
Modified:
   branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
   branches/rel_2_1/Open-ILS/src/sql/Pg/002.schema.config.sql
   branches/rel_2_1/Open-ILS/src/sql/Pg/005.schema.actors.sql
Log:
Patch from Niles Ingalls to make patron phone number searching more matchy.
With assistance from Mike Rylander on pointing out the needed indexes to keep
search fast, and from Mike Peters on arranging a last minute DCO :-)

Type numbers into a patron phone number field and get a match regardless of
the punctuation actually used in the database.



Modified: branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
===================================================================
--- branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-05-05 16:40:08 UTC (rev 20429)
+++ branches/rel_2_1/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-05-05 16:44:23 UTC (rev 20430)
@@ -680,7 +680,11 @@
 	my @phonev;
 	if ($pv) {
 		for my $p ( qw/day_phone evening_phone other_phone/ ) {
-			push @ps, "evergreen.lowercase($p) ~ ?";
+			if ($pv =~ /^\d+$/) {
+				push @ps, "evergreen.lowercase(REGEXP_REPLACE($p, '[^0-9]', '', 'g')) ~ ?";
+ 			} else {
+ 				push @ps, "evergreen.lowercase($p) ~ ?";
+ 			}
 			push @phonev, "^$pv";
 		}
 		$phone = '(' . join(' OR ', @ps) . ')';

Modified: branches/rel_2_1/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_1/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-05-05 16:40:08 UTC (rev 20429)
+++ branches/rel_2_1/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-05-05 16:44:23 UTC (rev 20430)
@@ -57,7 +57,7 @@
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0529'); -- miker, for Joseph Lewis and Michael Peters
+INSERT INTO config.upgrade_log (version) VALUES ('0530'); -- senator, for Niles Ingalls
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: branches/rel_2_1/Open-ILS/src/sql/Pg/005.schema.actors.sql
===================================================================
--- branches/rel_2_1/Open-ILS/src/sql/Pg/005.schema.actors.sql	2011-05-05 16:40:08 UTC (rev 20429)
+++ branches/rel_2_1/Open-ILS/src/sql/Pg/005.schema.actors.sql	2011-05-05 16:44:23 UTC (rev 20430)
@@ -88,6 +88,15 @@
 CREATE INDEX actor_usr_evening_phone_idx ON actor.usr (evergreen.lowercase(evening_phone));
 CREATE INDEX actor_usr_other_phone_idx ON actor.usr (evergreen.lowercase(other_phone));
 
+CREATE INDEX actor_usr_day_phone_idx_numeric ON actor.usr USING BTREE
+    (evergreen.lowercase(REGEXP_REPLACE(day_phone, '[^0-9]', '', 'g')));
+
+CREATE INDEX actor_usr_evening_phone_idx_numeric ON actor.usr USING BTREE
+    (evergreen.lowercase(REGEXP_REPLACE(evening_phone, '[^0-9]', '', 'g')));
+
+CREATE INDEX actor_usr_other_phone_idx_numeric ON actor.usr USING BTREE
+    (evergreen.lowercase(REGEXP_REPLACE(other_phone, '[^0-9]', '', 'g')));
+
 CREATE INDEX actor_usr_ident_value_idx ON actor.usr (evergreen.lowercase(ident_value));
 CREATE INDEX actor_usr_ident_value2_idx ON actor.usr (evergreen.lowercase(ident_value2));
 

Copied: branches/rel_2_1/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql (from rev 20429, trunk/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql)
===================================================================
--- branches/rel_2_1/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql	                        (rev 0)
+++ branches/rel_2_1/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql	2011-05-05 16:44:23 UTC (rev 20430)
@@ -0,0 +1,14 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0530'); -- senator
+
+CREATE INDEX actor_usr_day_phone_idx_numeric ON actor.usr USING BTREE 
+    (evergreen.lowercase(REGEXP_REPLACE(day_phone, '[^0-9]', '', 'g')));
+
+CREATE INDEX actor_usr_evening_phone_idx_numeric ON actor.usr USING BTREE 
+    (evergreen.lowercase(REGEXP_REPLACE(evening_phone, '[^0-9]', '', 'g')));
+
+CREATE INDEX actor_usr_other_phone_idx_numeric ON actor.usr USING BTREE 
+    (evergreen.lowercase(REGEXP_REPLACE(other_phone, '[^0-9]', '', 'g')));
+
+COMMIT;



More information about the open-ils-commits mailing list