[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. 592dc44c00ecea111636f7290264f5cdb5931a26

Evergreen Git git at git.evergreen-ils.org
Fri Apr 13 00:19:43 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_2 has been updated
       via  592dc44c00ecea111636f7290264f5cdb5931a26 (commit)
      from  a22cade28f2f9a712507b16c7613b4445844c969 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 592dc44c00ecea111636f7290264f5cdb5931a26
Author: Dan Scott <dan at coffeecode.net>
Date:   Fri Apr 6 14:52:20 2012 -0400

    Add pref_ou query filter for preferred library searching
    
    Include the user's "preferred search library" (as set in search
    preferences, falling back to home OU) in searches, specifically for the
    purposes of ensuring that located URIs at the user's preferred library
    would trigger hits where physical copies would be out of scope.
    
    Practical example:
    
    1. User sets preferred search library to BR1.
    
    2. They jump onto the catalogue, log in (which changes their search org
      to their preferred search library of BR1), but then for some reason
      change their search org in the org selector to BR3.
    
    3. They issue a search for "Harry Potter and the Philosopher's Stone".
      BR3 doesn't hold any copies or have any located URIs, but SYS1 (BR1's
      parent) has a PotterMore licence and has added their 856 $9 SYS1 to a
      bib record.
    
    As it currently stands, User is out of luck; they won't see any hits in
    search results as there are no copies or located URIs in the BR3 scope.
    
    The proposed enhancement would, however, make the search results contain
    a hit for "Harry Potter and the Philosopher's Stone" at the user's
    preferred search library.
    
    Sites can trigger the preferred library as part of the query filters
    using the "pref_ou(SHORTNAME)" syntax.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    
    Conflicts:
    
    	Open-ILS/src/sql/Pg/002.schema.config.sql

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
index 189ec6c..82ad1af 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm
@@ -748,6 +748,7 @@ Recognized search keys include:
  series  (se) - search series     *
  lang - limit by language (specifiy multiple langs with lang:l1 lang:l2 ...)
  site - search at specified org unit, corresponds to actor.org_unit.shortname
+ pref_ou - extend search to specified org unit, corresponds to actor.org_unit.shortname
  sort - sort type (title, author, pubdate)
  dir  - sort direction (asc, desc)
  available - if set to anything other than "false" or "0", limits to available items
@@ -805,7 +806,7 @@ sub multiclass_query {
 
     my $simple_class_re  = qr/((?:\w+(?:\|\w+)?):[^:]+?)$/;
     my $class_list_re    = qr/(?:keyword|title|author|subject|series)/;
-    my $modifier_list_re = qr/(?:site|dir|sort|lang|available)/;
+    my $modifier_list_re = qr/(?:site|dir|sort|lang|available|preflib)/;
 
     my $tmp_value = '';
     while ($query =~ s/$simple_class_re//so) {
@@ -841,6 +842,14 @@ sub multiclass_query {
             } else {
                 $logger->warn("'site:' query used on invalid org shortname: $value ... ignoring");
             }
+        } elsif($type eq 'pref_ou') {
+            # 'pref_ou' is the preferred org shortname.
+            my $e = new_editor();
+            if(my $org = $e->search_actor_org_unit({shortname => $value})->[0]) {
+                $arghash->{pref_ou} = $org->id if $org;
+            } else {
+                $logger->warn("'pref_ou:' query used on invalid org shortname: $value ... ignoring");
+            }
 
         } elsif($type eq 'available') {
             # limit to available
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
index f88affe..efd83e0 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
@@ -424,6 +424,7 @@ __PACKAGE__->add_search_filter( 'statuses' );
 __PACKAGE__->add_search_filter( 'locations' );
 __PACKAGE__->add_search_filter( 'location_groups' );
 __PACKAGE__->add_search_filter( 'site' );
+__PACKAGE__->add_search_filter( 'pref_ou' );
 __PACKAGE__->add_search_filter( 'lasso' );
 __PACKAGE__->add_search_filter( 'my_lasso' );
 __PACKAGE__->add_search_filter( 'depth' );
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
index 22b50f8..1da0115 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm
@@ -2911,7 +2911,6 @@ sub query_parser_fts {
     }
     $ou = actor::org_unit->search( { shortname => $ou } )->next->id if ($ou and $ou !~ /^(-)?\d+$/);
 
-
     # gather lasso, as with $ou
 	my $lasso = $args{lasso};
 	if (my ($filter) = $query->parse_tree->find_filter('lasso')) {
@@ -2933,6 +2932,13 @@ sub query_parser_fts {
     # if we have a lasso, go with that, otherwise ... ou
     $ou = $lasso if ($lasso);
 
+    # gather the preferred OU, if one is specified, as with $ou
+    my $pref_ou = $args{pref_ou};
+	$log->info("pref_ou = $pref_ou");
+	if (my ($filter) = $query->parse_tree->find_filter('pref_ou')) {
+            $pref_ou = $filter->args->[0] if (@{$filter->args});
+    }
+    $pref_ou = actor::org_unit->search( { shortname => $pref_ou } )->next->id if ($pref_ou and $pref_ou !~ /^(-)?\d+$/);
 
     # get the default $ou if we have nothing
 	$ou = actor::org_unit->search( { parent_ou => undef } )->next->id if (!$ou and !$lasso and !$mylasso);
@@ -3028,6 +3034,7 @@ sub query_parser_fts {
 	my $param_locations = '$${' . join(',', map { s/\$//go; "\"$_\""} @location) . '}$$';
 	my $staff = ($self->api_name =~ /staff/ or $query->parse_tree->find_modifier('staff')) ? "'t'" : "'f'";
 	my $metarecord = ($self->api_name =~ /metabib/ or $query->parse_tree->find_modifier('metabib') or $query->parse_tree->find_modifier('metarecord')) ? "'t'" : "'f'";
+	my $param_pref_ou = $pref_ou || 'NULL';
 
 	my $sth = metabib::metarecord_source_map->db_Main->prepare(<<"    SQL");
         SELECT  * -- bib search: $args{query}
@@ -3041,7 +3048,8 @@ sub query_parser_fts {
                     $param_check\:\:INT,
                     $param_limit\:\:INT,
                     $metarecord\:\:BOOL,
-                    $staff\:\:BOOL
+                    $staff\:\:BOOL,
+                    $param_pref_ou\:\:INT
                 );
     SQL
 
@@ -3184,6 +3192,7 @@ sub query_parser_fts_wrapper {
 
     $query = "estimation_strategy($args{estimation_strategy}) $query" if ($args{estimation_strategy});
     $query = "site($args{org_unit}) $query" if ($args{org_unit});
+    $query = "pref_ou($args{pref_ou}) $query" if ($args{pref_ou});
     $query = "depth($args{depth}) $query" if (defined($args{depth}));
     $query = "sort($args{sort}) $query" if ($args{sort});
     $query = "limit($args{limit}) $query" if ($args{limit});
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index d687de2..b4d77e2 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -112,6 +112,12 @@ sub _prepare_biblio_search {
         $query .= " site($site)";
     }
 
+    my $pref_ou = $ctx->{pref_ou};
+    if (defined($pref_ou) and $pref_ou ne '' and $pref_ou != $org and ($pref_ou ne $ctx->{aou_tree}->()->id)) {
+        my $plib = $ctx->{get_aou}->($pref_ou)->shortname;
+        $query .= " pref_ou($plib)";
+    }
+
     if (my $grp = $ctx->{copy_location_group}) {
         $query .= " location_groups($grp)";
     }
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 734f3a9..86311e1 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps
     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 ('0702', :eg_version); -- berick/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0704', :eg_version); -- dbs
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
index 9f23e17..26d9b53 100644
--- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
+++ b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
@@ -44,8 +44,8 @@ CREATE OR REPLACE FUNCTION search.query_parser_fts (
     param_check     INT,
     param_limit     INT,
     metarecord      BOOL,
-    staff           BOOL
- 
+    staff           BOOL,
+    param_pref_ou   INT DEFAULT NULL
 ) RETURNS SETOF search.search_result AS $func$
 DECLARE
 
@@ -100,6 +100,11 @@ BEGIN
         -- reserved for user lassos (ou_buckets/type='lasso') with ID passed in depth ... hack? sure.
     END IF;
 
+    IF param_pref_ou IS NOT NULL THEN
+        SELECT array_accum(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors(param_pref_ou);
+        luri_org_list := luri_org_list || tmp_int_list;
+    END IF;
+
     OPEN core_cursor FOR EXECUTE param_query;
 
     LOOP
diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/upgrade/0704.schema.query_parser_fts.sql
similarity index 88%
copy from Open-ILS/src/sql/Pg/300.schema.staged_search.sql
copy to Open-ILS/src/sql/Pg/upgrade/0704.schema.query_parser_fts.sql
index 9f23e17..12ab2f6 100644
--- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0704.schema.query_parser_fts.sql
@@ -1,38 +1,14 @@
-/*
- * Copyright (C) 2007-2010  Equinox Software, Inc.
- * Mike Rylander <miker at esilibrary.com> 
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-
-DROP SCHEMA IF EXISTS search CASCADE;
-
+-- Evergreen DB patch 0704.schema.query_parser_fts.sql
+--
+-- Add pref_ou query filter for preferred library searching
+--
 BEGIN;
 
-CREATE SCHEMA search;
-
-CREATE TABLE search.relevance_adjustment (
-    id          SERIAL  PRIMARY KEY,
-    active      BOOL    NOT NULL DEFAULT TRUE,
-    field       INT     NOT NULL REFERENCES config.metabib_field (id) DEFERRABLE INITIALLY DEFERRED,
-    bump_type   TEXT    NOT NULL CHECK (bump_type IN ('word_order','first_word','full_match')),
-    multiplier  NUMERIC NOT NULL DEFAULT 1.0
-);
-CREATE UNIQUE INDEX bump_once_per_field_idx ON search.relevance_adjustment ( field, bump_type );
 
-CREATE TYPE search.search_result AS ( id BIGINT, rel NUMERIC, record INT, total INT, checked INT, visible INT, deleted INT, excluded INT );
-CREATE TYPE search.search_args AS ( id INT, field_class TEXT, field_name TEXT, table_alias TEXT, term TEXT, term_type TEXT );
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0704', :eg_version);
 
+-- Create the new 11-parameter function, featuring param_pref_ou
 CREATE OR REPLACE FUNCTION search.query_parser_fts (
 
     param_search_ou INT,
@@ -44,8 +20,8 @@ CREATE OR REPLACE FUNCTION search.query_parser_fts (
     param_check     INT,
     param_limit     INT,
     metarecord      BOOL,
-    staff           BOOL
- 
+    staff           BOOL,
+    param_pref_ou   INT DEFAULT NULL
 ) RETURNS SETOF search.search_result AS $func$
 DECLARE
 
@@ -100,6 +76,11 @@ BEGIN
         -- reserved for user lassos (ou_buckets/type='lasso') with ID passed in depth ... hack? sure.
     END IF;
 
+    IF param_pref_ou IS NOT NULL THEN
+        SELECT array_accum(distinct id) INTO tmp_int_list FROM actor.org_unit_ancestors(param_pref_ou);
+        luri_org_list := luri_org_list || tmp_int_list;
+    END IF;
+
     OPEN core_cursor FOR EXECUTE param_query;
 
     LOOP
@@ -352,5 +333,9 @@ BEGIN
 END;
 $func$ LANGUAGE PLPGSQL;
 
-COMMIT;
+-- Drop the old 10-parameter function
+DROP FUNCTION IF EXISTS search.query_parser_fts (
+    INT, INT, TEXT, INT[], INT[], INT, INT, INT, BOOL, BOOL
+);
 
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 .../lib/OpenILS/Application/Search/Biblio.pm       |   11 ++++++++-
 .../Application/Storage/Driver/Pg/QueryParser.pm   |    1 +
 .../Application/Storage/Publisher/metabib.pm       |   13 +++++++++-
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |    6 +++++
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/300.schema.staged_search.sql   |    9 ++++++-
 ...ty_fix.sql => 0704.schema.query_parser_fts.sql} |   23 ++++++++++++++++---
 7 files changed, 55 insertions(+), 10 deletions(-)
 copy Open-ILS/src/sql/Pg/upgrade/{0631.schema.located_uri_visiblity_fix.sql => 0704.schema.query_parser_fts.sql} (94%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list