Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28934
Modified Files:
CommonSearch.pm
Log Message:
OIN-122: so we can provide a common interface, run through the
iterator once and collect the objects so we can count them up, then
wrap the collection in another iterator so the final page doesn't know
the difference
Index: CommonSearch.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action/CommonSearch.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** CommonSearch.pm 25 Feb 2005 00:01:06 -0000 1.19
--- CommonSearch.pm 26 Feb 2005 03:43:05 -0000 1.20
***************
*** 10,13 ****
--- 10,14 ----
use OpenInteract2::Exception qw( oi_error );
use OpenInteract2::ResultsManage;
+ use SPOPS::Iterator::WrapList;
$OpenInteract2::Action::CommonSearch::VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
***************
*** 56,68 ****
# If we're not using paged results, then just run the normal
! # search and get back an iterator
else {
$log->is_debug &&
$log->debug( "Search results not paged, using basic iterator" );
! $tmpl_params{iterator} = eval {
! $self->_search_build_and_run( \%tmpl_params )
};
$self->_search_catch_errors( "$@" );
}
--- 57,77 ----
# If we're not using paged results, then just run the normal
! # search and get back an iterator, but run through it once so we
! # can count up the results
else {
$log->is_debug &&
$log->debug( "Search results not paged, using basic iterator" );
! my $iter = eval {
! $self->_search_build_and_run();
};
$self->_search_catch_errors( "$@" );
+ my @items = $iter->get_all;
+ $tmpl_params{iterator} = SPOPS::Iterator::WrapList->new({
+ object_list => \@items
+ });
+ $tmpl_params{total_hits} = scalar @items;
+ $tmpl_params{page_num} = 1;
+ $tmpl_params{total_pages} = 1;
}
***************
*** 98,102 ****
$log->debug( "Running search for the first time" );
my $iterator = eval {
! $self->_search_build_and_run({ is_paged => 'yes' })
};
$self->_search_catch_errors( "$@" );
--- 107,111 ----
$log->debug( "Running search for the first time" );
my $iterator = eval {
! $self->_search_build_and_run();
};
$self->_search_catch_errors( "$@" );
***************
*** 252,256 ****
}
$log->is_info &&
! $log->info( "Got iterator from '$object_class' given query params" );
return $iter;
}
--- 261,265 ----
}
$log->is_info &&
! $log->info( "Got iterator from '$object_class' ok" );
return $iter;
}
|