/[webpac2]/Webpacus/lib/Webpacus/Model/WebPAC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/lib/Webpacus/Model/WebPAC.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 448 by dpavlin, Sun Mar 26 18:18:01 2006 UTC revision 449 by dpavlin, Tue May 2 10:21:06 2006 UTC
# Line 197  sub search { Line 197  sub search {
197    
198          my $template_filename = $args->{template} || $self->{template};          my $template_filename = $args->{template} || $self->{template};
199    
200          $args->{max} ||= $self->{'hits_for_pager'};          $args->{hits_on_page} ||= $self->{'hits_for_pager'};
201          if (! $args->{max}) {          if (! $args->{hits_on_page}) {
202                  $args->{max} = 100;                  $args->{hits_on_page} = 100;
203                  $log->warn("max not set when calling model. Using default of $args->{max}");                  $log->warn("max not set when calling model. Using default of $args->{hits_on_page}");
204          }          }
205    
206          my $times;      # store some times for benchmarking          my $times;      # store some times for benchmarking
# Line 215  sub search { Line 215  sub search {
215          }          }
216          $args->{depth} ||= 0;          $args->{depth} ||= 0;
217    
218          $log->debug("searching " . $self->{est_node}->{url} . " max: $args->{max} depth: $args->{depth} phrase: " . ($query || '[none]') );          $log->debug("searching " . $self->{est_node}->{url} . " hits on page: $args->{hits_on_page} depth: $args->{depth} phrase: " . ($query || '[none]') );
219    
220          #          #
221          # construct condition for Hyper Estraier          # construct condition for Hyper Estraier
# Line 233  sub search { Line 233  sub search {
233          $cond->set_options( $args->{options} ) if ($args->{options});          $cond->set_options( $args->{options} ) if ($args->{options});
234          $cond->set_order( $args->{order} ) if ($args->{order});          $cond->set_order( $args->{order} ) if ($args->{order});
235    
236          my $max = $args->{max} || 7;          my $hits_on_page = $args->{hits_on_page} || 7;
237          my $page = $args->{page} || 1;          my $page = $args->{page} || 1;
238          if ($page < 1) {          if ($page < 1) {
239                  $log->warn("page number $page < 1");                  $log->warn("page number $page < 1");
240                  $page = 1;                  $page = 1;
241          }          }
242    
243          $cond->set_max( $page * $max );          $cond->set_max( my $max = $page * $hits_on_page );
244            $cond->set_skip( my $skip = ( $page - 1 ) * $hits_on_page );
245    
246            $log->debug("search max: $max, skip: $skip");
247    
248          my $result = $self->{est_node}->search($cond, $args->{depth});          my $result = $self->{est_node}->search($cond, $args->{depth});
249          if (! $result) {          if (! $result) {
# Line 262  sub search { Line 265  sub search {
265    
266          my @results;          my @results;
267    
268          for my $i ( (($page - 1) * $max) .. ( $hits - 1 ) ) {          #for my $i ( (($page - 1) * $max) .. ( $hits - 1 ) ) {
269            for my $i ( 0 .. $max ) {
270    
271                  $t = time();                  $t = time();
272    

Legend:
Removed from v.448  
changed lines
  Added in v.449

  ViewVC Help
Powered by ViewVC 1.1.26