[open-ils-commits] [GIT] Evergreen ILS branch master updated. f49146ec6b6c0e54056a911a0f21e2d5c80a38b5

Evergreen Git git at git.evergreen-ils.org
Tue Dec 27 14:17:36 EST 2011


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, master has been updated
       via  f49146ec6b6c0e54056a911a0f21e2d5c80a38b5 (commit)
      from  3d358abbf1d069e66476e7edb21d6c43428521db (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 f49146ec6b6c0e54056a911a0f21e2d5c80a38b5
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 13:45:02 2011 -0500

    TPac: improve search depth extraction
    
    Improves how we determine the depth of a search.  The Order of
    operations:
    
    1. Depth encoded within the search query, e.g. depth(2)
    2. CGI depth param
    3. Default is to match the depth of the searched org unit
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Dan Scott <dan at coffeecode.net>

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 0db757b..77cfb38 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -108,14 +108,26 @@ sub _prepare_biblio_search {
         $site ||= $ctx->{aou_tree}->()->shortname;
     }
 
-
     my $depth;
-    if (defined($cgi->param('depth')) and not $query =~ /depth\(\d+\)/) {
-        $depth = defined $cgi->param('depth') ?
-            $cgi->param('depth') : $ctx->{get_aou}->($site)->ou_type->depth;
+    if ($query =~ /depth\(\d+\)/) {
+
+        # depth is encoded in the search query
+        ($depth) = ($query =~ /depth\((\d+)\)/);
+
+    } else {
+
+        if (defined $cgi->param('depth')) {
+            $depth = $cgi->param('depth');
+        } else {
+            # no depth specified.  match the depth to the search org
+            my ($org) = grep { $_->shortname eq $site } @{$ctx->{aou_list}->()};
+            $depth = $org->ou_type->depth;
+        }
         $query .= " depth($depth)";
     }
 
+    $logger->info("tpac: site=$site, depth=$depth, query=$query");
+
     return ($query, $site, $depth);
 }
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
index 1199d9a..92cea97 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -114,6 +114,13 @@ sub init_ro_object_cache {
         return $cache{map}{aou}{$org_id};
     };
 
+    # Returns a flat list of aou objects.  often easier to manage than a tree.
+    $ro_object_subs->{aou_list} = sub {
+        $ro_object_subs->{aou_tree}->(); # force the org tree to load
+        return [ values %{$cache{map}{aou}} ];
+    };
+
+
     # turns an ISO date into something TT can understand
     $ro_object_subs->{parse_datetime} = sub {
         my $date = shift;

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

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |   20 ++++++++++++++++----
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm   |    7 +++++++
 2 files changed, 23 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list