[open-ils-commits] r20429 - in trunk/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:40:12 EDT 2011


Author: senator
Date: 2011-05-05 12:40:08 -0400 (Thu, 05 May 2011)
New Revision: 20429

Added:
   trunk/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql
Modified:
   trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
   trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
   trunk/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: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-05-05 16:36:43 UTC (rev 20428)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm	2011-05-05 16:40:08 UTC (rev 20429)
@@ -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: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-05-05 16:36:43 UTC (rev 20428)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql	2011-05-05 16:40:08 UTC (rev 20429)
@@ -86,7 +86,7 @@
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0529', :eg_version); -- miker, for Joseph Lewis and Michael Peters
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0530', :eg_version); -- senator, for Niles Ingalls
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,

Modified: trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql	2011-05-05 16:36:43 UTC (rev 20428)
+++ trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql	2011-05-05 16:40:08 UTC (rev 20429)
@@ -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));
 

Added: trunk/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql	                        (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0530.schema.actor-usr-index-phone-fields-more.sql	2011-05-05 16:40:08 UTC (rev 20429)
@@ -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