[open-ils-commits] [GIT] Evergreen ILS branch QP_bucket_filter created. 8b13def082e3e9f623da06ec0e3e079373717d51
Evergreen Git
git at git.evergreen-ils.org
Tue Aug 2 15:02:39 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, QP_bucket_filter has been created
at 8b13def082e3e9f623da06ec0e3e079373717d51 (commit)
- Log -----------------------------------------------------------------
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
-----------------------------------------------------------------------
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list