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

Evergreen Git git at git.evergreen-ils.org
Thu Aug 4 10:42:21 EDT 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  9cd9478e7450ac48d0d522ceef5d4830b2e3aae9 (commit)
       via  9398a9ca85624f4e9a4cfc87fbd9f6d38f721457 (commit)
       via  d567c2b5c278f3ec291228a902b5d1ca1a25d64f (commit)
       via  492e02e90a797e73f6c3f214c81670c874061291 (commit)
       via  3a523a078311d23d1dd960070f59cf39d947b936 (commit)
       via  af34e9435cab57ec92072d540ff9c53b651ab491 (commit)
       via  18a10313fc0b1c2d909685cad28cba53a8daf846 (commit)
       via  33466952162f6cf93ac7d67433c94b61da662121 (commit)
       via  31102902d8b7cfefdb2b5dc9e3cb94e828567c2f (commit)
       via  8b13def082e3e9f623da06ec0e3e079373717d51 (commit)
       via  bbee2f0b778a4178ee6a173451540b634ffd2884 (commit)
       via  f882d5da9bb8323960b7d246197974c0fc3c14a6 (commit)
      from  6b1d17a5fd47f65564302e538c69671ac02b8f81 (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 9cd9478e7450ac48d0d522ceef5d4830b2e3aae9
Merge: 9398a9c 6b1d17a
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Wed Aug 3 16:42:34 2011 -0400

    Merge branch 'master' of git://git.evergreen-ils.org/Evergreen into QP_bucket_filter


commit 9398a9ca85624f4e9a4cfc87fbd9f6d38f721457
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Wed Aug 3 16:42:17 2011 -0400

    Cast needed
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

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 7e93ab2..e8949ef 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
@@ -635,7 +635,7 @@ sub toSQL {
     }
 
     if ($record_list and @{$record_list->args} > 0) {
-        $record_list = 'JOIN (VALUES (' . join('),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . ")) record_list(id) ON (record_list.id = $key)"
+        $record_list = 'JOIN (VALUES (' . join('),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . ")) record_list(id) ON (record_list.id::BIGINT = $key)"
     } else {
         $record_list = '';
     }

commit d567c2b5c278f3ec291228a902b5d1ca1a25d64f
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 20:05:53 2011 -0400

    Quote container id param for safety
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 d10016d..7e93ab2 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
@@ -627,9 +627,8 @@ sub toSQL {
                       JOIN container.${class}_bucket c ON (c.id = ci.bucket)
                       $rec_join
                 WHERE c.btype = > . $self->QueryParser->quote_value($ctype) .
-                    qq< AND c.id = $cid
-                      AND (c.pub IS TRUE $perm_join)) container ON (container.container_item = mrd.id)
-            >;
+                    qq< AND c.id = > . $self->QueryParser->quote_value($cid) .
+                    qq< AND (c.pub IS TRUE $perm_join)) container ON (container.container_item = mrd.id) >;
         } else {$container = ''};
     } else {
         $container = '';

commit 492e02e90a797e73f6c3f214c81670c874061291
Merge: 3a523a0 af34e94
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 20:02:28 2011 -0400

    Merge branch 'QP_bucket_filter' of git.evergreen-ils.org:evergreen/equinox into QP_bucket_filter


commit 3a523a078311d23d1dd960070f59cf39d947b936
Merge: 18a1031 5c2de55
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 20:01:49 2011 -0400

    Merge branch 'master' of git.evergreen-ils.org:Evergreen into QP_bucket_filter


commit af34e9435cab57ec92072d540ff9c53b651ab491
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Tue Aug 2 17:34:10 2011 -0400

    Fixed some syntax errors, but getting no results when I'd expect some
    
    I searched with this
    
        container(bre,bookbag,12,$authtoken)
    
    where $authtoken is substituted with an actual live authtoken for the
    user that owns that container, and here is the example generated query
    that returns no results:
    
      SELECT * FROM  search.query_parser_fts(
                4::INT,
                2::INT,
                $core_query_3553$SELECT  m.source AS id,
    ARRAY_ACCUM(DISTINCT m.source) AS records,
    1.0/((AVG(
            (1)
    ) * COALESCE( NULLIF( FIRST(mrd.attrs @> hstore('item_lang', $_3553$eng$_3553$)), FALSE )::INT * 5, 1)))::NUMERIC AS rel,
    1.0/((AVG(
            (1)
    ) * COALESCE( NULLIF( FIRST(mrd.attrs @> hstore('item_lang', $_3553$eng$_3553$)), FALSE )::INT * 5, 1)))::NUMERIC AS rank,
    FIRST(mrd.attrs->'date1') AS tie_break
    FROM  metabib.metarecord_source_map m
    JOIN metabib.record_attr mrd ON (m.source = mrd.id)
    
    JOIN ( SELECT ci.target_biblio_record_entry AS container_item
            FROM  container.biblio_record_entry_bucket_item ci
                  JOIN container.biblio_record_entry_bucket c ON (c.id = ci.bucket)
    
            WHERE c.btype = $_3553$bookbag$_3553$ AND c.id = 12
                  AND (c.pub IS TRUE OR c.owner = 1)) container ON (container.container_item = mrd.id)
    
    WHERE 1=1
    
    AND (TRUE)
    GROUP BY 1
    ORDER BY 4 ASC NULLS LAST, 5 DESC NULLS LAST, 3 DESC
    LIMIT 10000
    $core_query_3553$::TEXT,
                $${}$$::INT[],
                $${}$$::INT[],
                NULL::INT,
                1000::INT,
                10000::INT,
                'f'::BOOL,
                't'::BOOL
            );
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

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 b57870e..d10016d 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
@@ -621,16 +621,15 @@ sub toSQL {
             my ($u,$e) = $apputils->checksesperm($token) if ($token);
             $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e);
 
-            $container = <<"            SQL";
+            $container = qq<
         JOIN ( SELECT $rec_field AS container_item
                 FROM  container.${class}_bucket_item ci
                       JOIN container.${class}_bucket c ON (c.id = ci.bucket)
                       $rec_join
-                WHERE c.btype = $ctype
-                      AND c.id = $cid
-                      AND (c.pub IS TRUE $perm_join)) container ON ON (container.container_item = mrd.id)
-            SQL
-
+                WHERE c.btype = > . $self->QueryParser->quote_value($ctype) .
+                    qq< AND c.id = $cid
+                      AND (c.pub IS TRUE $perm_join)) container ON (container.container_item = mrd.id)
+            >;
         } else {$container = ''};
     } else {
         $container = '';

commit 18a10313fc0b1c2d909685cad28cba53a8daf846
Merge: 3346695 8b13def
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 15:01:55 2011 -0400

    Merge branch 'QP_bucket_filter' of git.evergreen-ils.org:evergreen/equinox into QP_bucket_filter


commit 33466952162f6cf93ac7d67433c94b61da662121
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 14:58:57 2011 -0400

    Actually JOIN the VALUES list; syntax copy/paste-o; use the correct field for bre containers
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 91d10db..b57870e 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
@@ -437,10 +437,10 @@ __PACKAGE__->add_search_filter( 'estimation_strategy' );
 __PACKAGE__->add_search_modifier( 'available' );
 __PACKAGE__->add_search_modifier( 'staff' );
 
-# Start from container data (bre, acn, acp)
+# Start from container data (bre, acn, acp): container(bre,bookbag,123,deadb33fdeadb33fdeadb33fdeadb33f)
 __PACKAGE__->add_search_filter( 'container' );
 
-# Start from a list of record ids
+# Start from a list of record ids, either bre or metarecords, depending on the #metabib modifier
 __PACKAGE__->add_search_filter( 'record_list' );
 
 # used internally, but generally not user-settable
@@ -599,7 +599,7 @@ sub toSQL {
 
         my $perm_join = '';
         my $rec_join = '';
-        my $rec_field = 'ci.id';
+        my $rec_field = 'ci.target_biblio_record_entry';
 
         if ($class eq 'bre') {
             $class = 'biblio_record_entry';
@@ -618,8 +618,8 @@ sub toSQL {
         } else { $class = undef };
 
         if ($class) {
-            my ($u,$e) = $apputils->checksesperm($token); if ($token);
-            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e)
+            my ($u,$e) = $apputils->checksesperm($token) if ($token);
+            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e);
 
             $container = <<"            SQL";
         JOIN ( SELECT $rec_field AS container_item
@@ -637,7 +637,7 @@ sub toSQL {
     }
 
     if ($record_list and @{$record_list->args} > 0) {
-        $record_list = '(VALUES (' . join('::BIGINT),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . "::BIGINT)) record_list(id) ON (record_list.id = $key)"
+        $record_list = 'JOIN (VALUES (' . join('),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . ")) record_list(id) ON (record_list.id = $key)"
     } else {
         $record_list = '';
     }

commit 31102902d8b7cfefdb2b5dc9e3cb94e828567c2f
Author: Mike Rylander <mrylander at gmail.com>
Date:   Fri Jul 22 15:10:23 2011 -0400

    Add cointainer() and record_list() filters to QueryParser
    
    The container() filter takes 3 or 4 positional params:
      - class (bre, acn, acp, au)
      - type  (bookbag, etc -- btype of the container)
      - id    (container id)
      - token (authtoken, optional, for checkin ownership of non-public containers)
    
    The record_list() filter takes a list of record ids to restrict the search by.
    These are bib ids by default, but are treated as metarecord ids in the presence
    of the #metabib (aka #metarecord) modifier.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 8cd490c..91d10db 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
@@ -437,6 +437,12 @@ __PACKAGE__->add_search_filter( 'estimation_strategy' );
 __PACKAGE__->add_search_modifier( 'available' );
 __PACKAGE__->add_search_modifier( 'staff' );
 
+# Start from container data (bre, acn, acp)
+__PACKAGE__->add_search_filter( 'container' );
+
+# Start from a list of record ids
+__PACKAGE__->add_search_filter( 'record_list' );
+
 # used internally, but generally not user-settable
 __PACKAGE__->add_search_filter( 'preferred_language' );
 __PACKAGE__->add_search_filter( 'preferred_language_weight' );
@@ -458,6 +464,9 @@ package OpenILS::Application::Storage::Driver::Pg::QueryParser::query_plan;
 use base 'QueryParser::query_plan';
 use OpenSRF::Utils::Logger qw($logger);
 use Data::Dumper;
+use OpenILS::Application::AppUtils;
+my $apputils = "OpenILS::Application::AppUtils";
+
 
 sub toSQL {
     my $self = shift;
@@ -558,6 +567,8 @@ sub toSQL {
     my ($after) = $self->find_filter('after');
     my ($during) = $self->find_filter('during');
     my ($between) = $self->find_filter('between');
+    my ($container) = $self->find_filter('container');
+    my ($record_list) = $self->find_filter('record_list');
 
     if ($before and @{$before->args} == 1) {
         $before = "AND (mrd.attrs->'date1') <= " . $self->QueryParser->quote_value($before->args->[0]);
@@ -583,6 +594,54 @@ sub toSQL {
         $between = '';
     }
 
+    if ($container and @{$container->args} >= 3) {
+        my ($class, $ctype, $cid, $token) = @{ $container->args };
+
+        my $perm_join = '';
+        my $rec_join = '';
+        my $rec_field = 'ci.id';
+
+        if ($class eq 'bre') {
+            $class = 'biblio_record_entry';
+        } elsif ($class eq 'acn') {
+            $class = 'call_number';
+            $rec_field = 'cn.record';
+            $rec_join = 'JOIN asset.call_number cn ON (ci.target_call_number = cn.id)';
+        } elsif ($class eq 'acp') {
+            $class = 'copy';
+            $rec_field = 'cn.record';
+            $rec_join = 'JOIN asset.copy cp ON (ci.target_copy = cp.id) JOIN asset.call_number cn ON (cp.call_number = cn.id)';
+#        } elsif ($class eq 'au') {
+#            $class = 'user';
+#            $rec_field = 'cn.record';
+#            $rec_join = 'JOIN asset.call_number cn ON ci.target_call_number = cn.id';
+        } else { $class = undef };
+
+        if ($class) {
+            my ($u,$e) = $apputils->checksesperm($token); if ($token);
+            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e)
+
+            $container = <<"            SQL";
+        JOIN ( SELECT $rec_field AS container_item
+                FROM  container.${class}_bucket_item ci
+                      JOIN container.${class}_bucket c ON (c.id = ci.bucket)
+                      $rec_join
+                WHERE c.btype = $ctype
+                      AND c.id = $cid
+                      AND (c.pub IS TRUE $perm_join)) container ON ON (container.container_item = mrd.id)
+            SQL
+
+        } else {$container = ''};
+    } else {
+        $container = '';
+    }
+
+    if ($record_list and @{$record_list->args} > 0) {
+        $record_list = '(VALUES (' . join('::BIGINT),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . "::BIGINT)) record_list(id) ON (record_list.id = $key)"
+    } else {
+        $record_list = '';
+    }
+
     my $core_limit = $self->QueryParser->core_limit || 25000;
 
     my $flat_where = $$flat_plan{where};
@@ -600,6 +659,8 @@ SELECT  $key AS id,
         FIRST(mrd.attrs->'date1') AS tie_break
   FROM  metabib.metarecord_source_map m
         JOIN metabib.record_attr mrd ON (m.source = mrd.id)
+        $container
+        $record_list
         $$flat_plan{from}
   WHERE 1=1
         $before

commit 8b13def082e3e9f623da06ec0e3e079373717d51
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 14:58:57 2011 -0400

    Actually JOIN the VALUES list; syntax copy/paste-o; use the correct field for bre containers
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 91d10db..b57870e 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
@@ -437,10 +437,10 @@ __PACKAGE__->add_search_filter( 'estimation_strategy' );
 __PACKAGE__->add_search_modifier( 'available' );
 __PACKAGE__->add_search_modifier( 'staff' );
 
-# Start from container data (bre, acn, acp)
+# Start from container data (bre, acn, acp): container(bre,bookbag,123,deadb33fdeadb33fdeadb33fdeadb33f)
 __PACKAGE__->add_search_filter( 'container' );
 
-# Start from a list of record ids
+# Start from a list of record ids, either bre or metarecords, depending on the #metabib modifier
 __PACKAGE__->add_search_filter( 'record_list' );
 
 # used internally, but generally not user-settable
@@ -599,7 +599,7 @@ sub toSQL {
 
         my $perm_join = '';
         my $rec_join = '';
-        my $rec_field = 'ci.id';
+        my $rec_field = 'ci.target_biblio_record_entry';
 
         if ($class eq 'bre') {
             $class = 'biblio_record_entry';
@@ -618,8 +618,8 @@ sub toSQL {
         } else { $class = undef };
 
         if ($class) {
-            my ($u,$e) = $apputils->checksesperm($token); if ($token);
-            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e)
+            my ($u,$e) = $apputils->checksesperm($token) if ($token);
+            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e);
 
             $container = <<"            SQL";
         JOIN ( SELECT $rec_field AS container_item
@@ -637,7 +637,7 @@ sub toSQL {
     }
 
     if ($record_list and @{$record_list->args} > 0) {
-        $record_list = '(VALUES (' . join('::BIGINT),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . "::BIGINT)) record_list(id) ON (record_list.id = $key)"
+        $record_list = 'JOIN (VALUES (' . join('),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . ")) record_list(id) ON (record_list.id = $key)"
     } else {
         $record_list = '';
     }

commit bbee2f0b778a4178ee6a173451540b634ffd2884
Merge: f882d5d e1658e2
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Aug 2 14:39:18 2011 -0400

    Merge branch 'master' of git.evergreen-ils.org:Evergreen into QP_bucket_filter


commit f882d5da9bb8323960b7d246197974c0fc3c14a6
Author: Mike Rylander <mrylander at gmail.com>
Date:   Fri Jul 22 15:10:23 2011 -0400

    Add cointainer() and record_list() filters to QueryParser
    
    The container() filter takes 3 or 4 positional params:
      - class (bre, acn, acp, au)
      - type  (bookbag, etc -- btype of the container)
      - id    (container id)
      - token (authtoken, optional, for checkin ownership of non-public containers)
    
    The record_list() filter takes a list of record ids to restrict the search by.
    These are bib ids by default, but are treated as metarecord ids in the presence
    of the #metabib (aka #metarecord) modifier.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 8cd490c..91d10db 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
@@ -437,6 +437,12 @@ __PACKAGE__->add_search_filter( 'estimation_strategy' );
 __PACKAGE__->add_search_modifier( 'available' );
 __PACKAGE__->add_search_modifier( 'staff' );
 
+# Start from container data (bre, acn, acp)
+__PACKAGE__->add_search_filter( 'container' );
+
+# Start from a list of record ids
+__PACKAGE__->add_search_filter( 'record_list' );
+
 # used internally, but generally not user-settable
 __PACKAGE__->add_search_filter( 'preferred_language' );
 __PACKAGE__->add_search_filter( 'preferred_language_weight' );
@@ -458,6 +464,9 @@ package OpenILS::Application::Storage::Driver::Pg::QueryParser::query_plan;
 use base 'QueryParser::query_plan';
 use OpenSRF::Utils::Logger qw($logger);
 use Data::Dumper;
+use OpenILS::Application::AppUtils;
+my $apputils = "OpenILS::Application::AppUtils";
+
 
 sub toSQL {
     my $self = shift;
@@ -558,6 +567,8 @@ sub toSQL {
     my ($after) = $self->find_filter('after');
     my ($during) = $self->find_filter('during');
     my ($between) = $self->find_filter('between');
+    my ($container) = $self->find_filter('container');
+    my ($record_list) = $self->find_filter('record_list');
 
     if ($before and @{$before->args} == 1) {
         $before = "AND (mrd.attrs->'date1') <= " . $self->QueryParser->quote_value($before->args->[0]);
@@ -583,6 +594,54 @@ sub toSQL {
         $between = '';
     }
 
+    if ($container and @{$container->args} >= 3) {
+        my ($class, $ctype, $cid, $token) = @{ $container->args };
+
+        my $perm_join = '';
+        my $rec_join = '';
+        my $rec_field = 'ci.id';
+
+        if ($class eq 'bre') {
+            $class = 'biblio_record_entry';
+        } elsif ($class eq 'acn') {
+            $class = 'call_number';
+            $rec_field = 'cn.record';
+            $rec_join = 'JOIN asset.call_number cn ON (ci.target_call_number = cn.id)';
+        } elsif ($class eq 'acp') {
+            $class = 'copy';
+            $rec_field = 'cn.record';
+            $rec_join = 'JOIN asset.copy cp ON (ci.target_copy = cp.id) JOIN asset.call_number cn ON (cp.call_number = cn.id)';
+#        } elsif ($class eq 'au') {
+#            $class = 'user';
+#            $rec_field = 'cn.record';
+#            $rec_join = 'JOIN asset.call_number cn ON ci.target_call_number = cn.id';
+        } else { $class = undef };
+
+        if ($class) {
+            my ($u,$e) = $apputils->checksesperm($token); if ($token);
+            $perm_join = 'OR c.owner = ' . $u->id if ($u && !$e)
+
+            $container = <<"            SQL";
+        JOIN ( SELECT $rec_field AS container_item
+                FROM  container.${class}_bucket_item ci
+                      JOIN container.${class}_bucket c ON (c.id = ci.bucket)
+                      $rec_join
+                WHERE c.btype = $ctype
+                      AND c.id = $cid
+                      AND (c.pub IS TRUE $perm_join)) container ON ON (container.container_item = mrd.id)
+            SQL
+
+        } else {$container = ''};
+    } else {
+        $container = '';
+    }
+
+    if ($record_list and @{$record_list->args} > 0) {
+        $record_list = '(VALUES (' . join('::BIGINT),(', map  { $self->QueryParser->quote_value($_) } @{ $record_list->args}) . "::BIGINT)) record_list(id) ON (record_list.id = $key)"
+    } else {
+        $record_list = '';
+    }
+
     my $core_limit = $self->QueryParser->core_limit || 25000;
 
     my $flat_where = $$flat_plan{where};
@@ -600,6 +659,8 @@ SELECT  $key AS id,
         FIRST(mrd.attrs->'date1') AS tie_break
   FROM  metabib.metarecord_source_map m
         JOIN metabib.record_attr mrd ON (m.source = mrd.id)
+        $container
+        $record_list
         $$flat_plan{from}
   WHERE 1=1
         $before

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

Summary of changes:
 .../Application/Storage/Driver/Pg/QueryParser.pm   |   59 ++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list